Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
AbstractGC.h
1 /*
2  * AbstractGC 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_ABSTRACTGC_H_
22 #define ELM_ALLOC_ABSTRACTGC_H_
23 
24 #include <elm/data/List.h>
25 #include <elm/types.h>
26 
27 namespace elm {
28 
29 class AbstractGC;
30 
31 class GCManager {
32 public:
33  virtual ~GCManager();
34  virtual void collect(AbstractGC& gc) = 0;
35  virtual void clean(void *p);
36 };
37 
38 class AbstractGC {
39 public:
40  inline AbstractGC(GCManager& m): manager(m) { }
41  virtual ~AbstractGC();
42 
43  // allocator interface
44  virtual void *allocate(t::size size) = 0;
45  virtual void free(void *block);
46  template <class T> void *alloc() { return allocate(sizeof(T)); }
47 
48  // GC part
49  virtual void runGC() = 0;
50  virtual bool mark(void *data, t::size size) = 0;
51  virtual void disable() = 0;
52  virtual void enable() = 0;
53  virtual void clean() = 0;
54 
55 protected:
57 };
58 
59 } // elm
60 
61 #endif /* ELM_ALLOC_ABSTRACTGC_H_ */
Definition: AbstractGC.h:38
virtual bool mark(void *data, t::size size)=0
virtual void disable()=0
GCManager & manager
Definition: AbstractGC.h:56
AbstractGC(GCManager &m)
Definition: AbstractGC.h:40
virtual void * allocate(t::size size)=0
virtual void runGC()=0
void * alloc()
Definition: AbstractGC.h:46
virtual void clean()=0
virtual void enable()=0
virtual ~AbstractGC()
Definition: alloc_AbstractGC.cpp:90
virtual void free(void *block)
Definition: alloc_AbstractGC.cpp:125
Definition: AbstractGC.h:31
virtual ~GCManager()
Definition: alloc_AbstractGC.cpp:37
virtual void clean(void *p)
Definition: alloc_AbstractGC.cpp:54
virtual void collect(AbstractGC &gc)=0
Printable< T, M > p(const T &data, const M &man)
Definition: Output.h:302
uint64 size
Definition: arch.h:35
Definition: adapter.h:26