DynamicObjectPool.h++
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __ccxx_DynamicObjectPool_hxx
00024 #define __ccxx_DynamicObjectPool_hxx
00025
00026 #include <commonc++/Common.h++>
00027 #include <commonc++/ObjectPool.h++>
00028
00029 #include <typeinfo>
00030
00031 namespace ccxx {
00032
00045 template <class T> class DynamicObjectPool
00046 : public ObjectPool<T>
00047 {
00048 public:
00049
00058 DynamicObjectPool(size_t size, void (*resetFunc)(T *), bool lazy = false);
00059
00063 ~DynamicObjectPool() throw();
00064
00071 T *reserve() throw(ObjectPoolException);
00072
00079 void release(T *elem) throw(ObjectPoolException);
00080
00081 private:
00082
00083 struct Link
00084 {
00085 T data;
00086 Link *next;
00087 };
00088
00089 void (*_resetFunc)(T *);
00090 Link *_list;
00091 Link *_freeList;
00092 Link *_usedList;
00093 };
00094
00095 #include <commonc++/DynamicObjectPoolImpl.h++>
00096
00097 };
00098
00099 #endif // __ccxx_DynamicObjectPool_hxx