| File lib/felix/rtl/flx_collector.hpp |
GODI Package
apps-felix |
#line 419 "lpsrc/flx_gc.ipk"
#ifndef FLX_COLLECTOR
#define FLX_COLLECTOR
#include "flx_gc.hpp"
#include <map>
namespace flx {
namespace gc {
namespace collector {
using namespace generic;
struct FLX_RTL_EXTERN malloc_free;
struct FLX_RTL_EXTERN flx_collector_t;
struct FLX_RTL_EXTERN malloc_free : public virtual allocator_t
{
void *allocate(std::size_t);
void deallocate(void *, std::size_t);
};
struct FLX_RTL_EXTERN flx_collector_t : public collector_t
{
flx_collector_t(allocator_t *);
~flx_collector_t();
// allocator
void *allocate(gc_shape_t *ptr_map, unsigned long);
// collector (returns number of objects collected)
unsigned long collect();
// add and remove roots
void add_root(void *memory);
void remove_root(void *memory);
//
void check();
bool check_client_pointer(void *);
bool check_frame_pointer(frame_t *);
// statistics
unsigned long get_allocation_count()const;
unsigned long get_root_count()const;
unsigned long get_allocation_amt()const;
private:
bool collecting;
unsigned long allocation_count;
unsigned long root_count;
unsigned long allocation_amt;
void deallocate(frame_t *frame);
// calls unlink and dispose
void unlink(frame_t *frame);
void dispose(frame_t *frame);
// calls post_delete or delete_frame
void post_delete(frame_t *frame);
void delete_frame(frame_t *frame);
unsigned long reap();
void mark();
unsigned long sweep(); // calls scan_object
void scan_object(frame_t *frame);
frame_t *first;
frame_t *to_delete;
typedef std::map<frame_t*,unsigned long, std::less<frame_t*> > rootmap_t;
rootmap_t roots;
bool parity;
allocator_t *allocator;
};
}}} // end namespaces
#endif