00001
00016 #ifndef __MemoryPool_H__
00017 #define __MemoryPool_H__
00018
00019
00020
00021
00022
00023
00024 template<class TYPE>
00025 class MemoryPool
00026 {
00027 public:
00031 MemoryPool(
00032 int entriesPerBlock = 64
00033 );
00034
00038 ~MemoryPool();
00039
00046 TYPE* Allocate();
00047
00051 void Free(
00052 TYPE* object
00053 );
00054
00061 bool IsInUse() const;
00062
00063 private:
00067 void CreateBlock();
00068
00069 private:
00070 int entriesPerBlock_;
00071 int usedEntriesCount_;
00072
00073 TYPE** entries_;
00074 int entriesSize_;
00075 int entriesCount_;
00076
00077 TYPE** blocks_;
00078 int blocksSize_;
00079 int blocksCount_;
00080
00081 };
00082
00083
00084 #include "MemoryPool.inl"
00085
00086 #endif