Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
ListGC.h
1 /*
2  * ListGC class interface
3  *
4  * This file is part of OTAWA
5  * Copyright (c) 2010, IRIT UPS.
6  *
7  * OTAWA is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * OTAWA is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OTAWA; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 #ifndef ELM_ALLOC_LISTGC__H_
22 #define ELM_ALLOC_LISTGC__H_
23 
24 #include <elm/alloc/AbstractGC.h>
25 
26 namespace elm {
27 
28 class ListGC: public AbstractGC {
29  class block_t;
30 public:
31 
32  ListGC(GCManager& m, int limit = 1024);
33  ~ListGC();
34 
35  void *allocate(t::size size) override;
36  void runGC() override;
37  bool mark(void *data, t::size size) override;
38  void disable() override;
39  void enable() override;
40  void clean() override;
41 
42 private:
43  inline bool gcNeeded() const { return !dis && cnt - lcnt > lim; }
44  int lcnt, cnt, lim;
45  block_t *head;
46  bool dis;
47 };
48 
49 } // elm
50 
51 #endif /* ELM_ALLOC_LISTGC__H_ */
elm::ListGC::enable
void enable() override
Definition: alloc_ListGC.cpp:136
elm::ListGC::~ListGC
~ListGC()
Definition: alloc_ListGC.cpp:76
elm::GCManager
Definition: AbstractGC.h:31
elm::AbstractGC
Definition: AbstractGC.h:38
elm::ListGC::block_t
Definition: alloc_ListGC.cpp:38
elm::ListGC::runGC
void runGC() override
Definition: alloc_ListGC.cpp:95
elm
Definition: adapter.h:26
elm::ListGC::ListGC
ListGC(GCManager &m, int limit=1024)
Definition: alloc_ListGC.cpp:66
elm::ListGC::clean
void clean() override
Definition: alloc_ListGC.cpp:143
elm::t::size
uint64 size
Definition: arch.h:35
elm::ListGC::disable
void disable() override
Definition: alloc_ListGC.cpp:131
elm::ListGC
Definition: ListGC.h:28
elm::ListGC::mark
bool mark(void *data, t::size size) override
Definition: alloc_ListGC.cpp:123
elm::ListGC::allocate
void * allocate(t::size size) override
Definition: alloc_ListGC.cpp:81