diff options
author | Teddy <ted.sybil@gmail.com> | 2013-08-12 19:37:57 +0800 |
---|---|---|
committer | Teddy <ted.sybil@gmail.com> | 2013-08-12 19:37:57 +0800 |
commit | 4d3ed205fc2b86180f81fea388e488f5fa96cef9 (patch) | |
tree | 31f8ad22e11da45a439d5aad873ba08a1896be81 /gc.cpp | |
parent | 301c949362d243bb6b69956355e0e7ecccc43ce4 (diff) |
basic gc
Diffstat (limited to 'gc.cpp')
-rw-r--r-- | gc.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -9,15 +9,21 @@ typedef unsigned long long ull; static EvalObj *gcq[GC_QUEUE_SIZE]; +GarbageCollector::GarbageCollector() { + mapping.clear(); + pend_cnt = 0; + pending_list = NULL; +} + GarbageCollector::PendingEntry::PendingEntry( EvalObj *_obj, PendingEntry *_next) : obj(_obj), next(_next) {} -void GarbageCollector::expose(EvalObj *ptr) { +void GarbageCollector::expose(EvalObj *ptr, bool delay) { bool flag = mapping.count(ptr); if (flag) { - if (!--mapping[ptr]) + if (!--mapping[ptr] && !delay) { #ifdef GC_DEBUG fprintf(stderr, "GC: 0x%llx pending. \n", (ull)ptr); @@ -80,4 +86,3 @@ EvalObj *GarbageCollector::attach(EvalObj *ptr) { return ptr; // passing through } -GarbageCollector gc; |