flx_ts_collector.hpp

00001 #line 840 "./lpsrc/flx_gc.pak"
00002 #ifndef __FLX_TS_COLLECTOR_H__
00003 #define __FLX_TS_COLLECTOR_H__
00004 #include "flx_collector.hpp"
00005 #include "pthread_mutex.hpp"
00006 
00007 namespace flx {
00008 namespace gc {
00009 namespace collector {
00010 
00011 /// Naive thread safe Mark and Sweep Collector.
00012 struct PTHREAD_EXTERN flx_ts_collector_t :
00013   public flx::gc::collector::flx_collector_t
00014 {
00015   flx_ts_collector_t(allocator_t *);
00016   ~flx_ts_collector_t();
00017 
00018 private:
00019   /// allocator
00020   void *v_allocate(gc_shape_t *ptr_map, unsigned long);
00021 
00022   /// collector (returns number of objects collected)
00023   unsigned long v_collect();
00024 
00025   // add and remove roots
00026   void v_add_root(void *memory);
00027   void v_remove_root(void *memory);
00028 
00029   // statistics
00030   unsigned long v_get_allocation_count()const;
00031   unsigned long v_get_root_count()const;
00032   unsigned long v_get_allocation_amt()const;
00033 
00034 private:
00035   mutable flx::pthread::flx_mutex_t mut;
00036 };
00037 
00038 }}} // end namespaces
00039 #endif
00040 

Generated on Sat Aug 25 21:22:58 2007 for Felix by  doxygen 1.5.1