--- parser3/src/include/pa_pool.h 2003/01/21 15:51:10 1.86 +++ parser3/src/include/pa_pool.h 2003/03/18 09:53:01 1.86.4.2 @@ -9,7 +9,7 @@ #ifndef PA_POOL_H #define PA_POOL_H -static const char* IDENT_POOL_H="$Date: 2003/01/21 15:51:10 $"; +static const char* IDENT_POOL_H="$Date: 2003/03/18 09:53:01 $"; #include "pa_config_includes.h" @@ -37,6 +37,12 @@ class Pool { public: Pool(void *astorage); + ~Pool(); + + //{@ collector issues + void collect_garbage(); + void log_high_watermark(const char *msg); + //}@ //{@ statistics size_t total_allocated() { return ftotal_allocated; } @@ -47,6 +53,11 @@ public: void *get_context() { return fcontext; } /// allocates some bytes on pool + void *malloc_atomic(size_t size, int place=0) { + return check(real_malloc_atomic(size, place), size); + } + + /// allocates some bytes on pool void *malloc(size_t size, int place=0) { return check(real_malloc(size, place), size); } @@ -56,7 +67,7 @@ public: } /// registers a routine to clean up non-pooled allocations - void register_cleanup(void (*cleanup) (void *), void *data) { + void register_cleanup(void (*cleanup) (void *, void *), void *data) { if(!real_register_cleanup(cleanup, data)) fail_register_cleanup(); } @@ -112,9 +123,12 @@ private: //{ /// @name implementation defined + void real_init(); + void real_finit(); void *real_malloc(size_t size, int place); + void *real_malloc_atomic(size_t size, int place); void *real_calloc(size_t size); - bool real_register_cleanup(void (*cleanup) (void *), void *data); + bool real_register_cleanup(void (*cleanup) (void *,void *), void *data); //} private: @@ -157,9 +171,12 @@ private: //disabled @see NEW */ -// all classes that are members parents of packed class [String] -// sould be packed also to avoid sparc odd st/lduh problem -#include "pa_pragma_pack_begin.h" +/** + @todo: try to remember the meaning of this old comment: + all classes that are members parents of packed class [String] + sould be packed also to avoid sparc odd st/lduh problem + [packing is unacceptable for garbage collector] +*/ class Pooled { // the pool i'm allocated on Pool *fpool; @@ -184,8 +201,9 @@ public: //{ /// @name useful wrapper around pool void *malloc(size_t size, int place=0) const { return fpool->malloc(size, place); } + void *malloc_atomic(size_t size, int place=0) const { return fpool->malloc_atomic(size, place); } void *calloc(size_t size) const { return fpool->calloc(size); } - void register_cleanup(void (*cleanup) (void *), void *data) { fpool->register_cleanup(cleanup, data); } + void register_cleanup(void (*cleanup) (void *, void *), void *data) { fpool->register_cleanup(cleanup, data); } void *copy(const void *buf, const size_t size) { return fpool->copy(buf, size); } char *copy(const char *cstr) { return fpool->copy(cstr); } #ifdef XML @@ -206,7 +224,7 @@ public: #endif //} }; -#include "pa_pragma_pack_end.h" + /// useful macro for creating objects on current Pooled object Pooled::pool() #define NEW new(pool())