aboutsummaryrefslogtreecommitdiff
path: root/gc.h
blob: 838021098983ba18462233bdaf8cfa3c54e40675 (plain) (blame)
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
#ifndef GC_H
#define GC_H

#include "model.h"
#include <map>

const int GC_QUEUE_SIZE = 262144;

typedef std::map<EvalObj*, size_t> EvalObj2Int;

class GarbageCollector {

    struct PendingEntry {
        EvalObj *obj;
        PendingEntry *next;
        PendingEntry(EvalObj *obj, PendingEntry *next);
    };

    EvalObj2Int mapping;
    size_t pend_cnt;
    PendingEntry *pending_list;
    bool collecting;

    public:
    GarbageCollector();
    void force();
    void expose(EvalObj *ptr);
    EvalObj *attach(EvalObj *ptr);
};

extern GarbageCollector gc;

#endif