diff options
author | Teddy <[email protected]> | 2013-08-14 15:34:03 +0800 |
---|---|---|
committer | Teddy <[email protected]> | 2013-08-14 15:34:03 +0800 |
commit | be368fbac6b8d80033ccb8e4138b55c4b0954c34 (patch) | |
tree | c36d4418568b30eccba02788bc86ec55404fcebb | |
parent | 4c083e4776a7bff4683dc3f64d7ccd83dbb3d235 (diff) |
ready for alpha 2
-rw-r--r-- | eval.cpp | 3 | ||||
-rw-r--r-- | gc.cpp | 7 | ||||
-rw-r--r-- | gc.h | 1 | ||||
-rw-r--r-- | main.cpp | 6 |
4 files changed, 11 insertions, 6 deletions
@@ -207,8 +207,7 @@ EvalObj *Evaluator::run_expr(Pair *prog) { call(args, envt, cont, top_ptr); else throw TokenError(opt->ext_repr(), SYN_ERR_CAN_NOT_APPLY); - gc.force(); - gc.cycle_resolve(); + gc.collect(); } } } @@ -151,6 +151,13 @@ void GarbageCollector::cycle_resolve() { #ifdef GC_INFO fprintf(stderr, "GC: cycle resolved.\n"); #endif +} + +void GarbageCollector::collect() { + force(); + if (mapping.size() < resolve_threshold) + return; + cycle_resolve(); force(); } @@ -37,6 +37,7 @@ class GarbageCollector { public: GarbageCollector(); + void collect(); void cycle_resolve(); void force(); void expose(EvalObj *ptr); @@ -35,8 +35,7 @@ void load_file(const char *fname) { { fprintf(stderr, "An error occured: %s\n", e.get_msg().c_str()); } - gc.force(); - gc.cycle_resolve(); + gc.collect(); } } @@ -109,7 +108,6 @@ int main(int argc, char **argv) { { fprintf(stderr, "An error occured: %s\n", e.get_msg().c_str()); } - gc.force(); - gc.cycle_resolve(); + gc.collect(); } } |