-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathGCObject.h
45 lines (36 loc) · 904 Bytes
/
GCObject.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef GC_OBJECT_H
#define GC_OBJECT_H
struct GCObject {
enum GCState {
GCS_Unaccess, GCS_Unscan, GCS_Scaned,
};
enum ObjType {
OT_String, OT_Table, OT_Function, OT_Stack,
};
GCObject(ObjType _objType): next(NULL), gcState(GCS_Unaccess), objType(_objType){}
GCObject* gcAccess() {
if (gcState == GCS_Unaccess) {
gcState = GCS_Unscan;
return this;
}
return NULL;
}
GCObject *next;
GCState gcState;
const ObjType objType;
};
class GCObjectManager {
public:
GCObjectManager();
~GCObjectManager();
void performFullGC();
void linkObject(GCObject *obj);
int getObjCount() const { return m_objCount;}
private:
GCObjectManager(const GCObjectManager&);
GCObjectManager& operator = (const GCObjectManager&);
private:
GCObject *m_headObj;
int m_objCount;
};
#endif