00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __UT_SmallObjectAllocator__
00020 #define __UT_SmallObjectAllocator__
00021
00022 #include "UT_API.h"
00023 #include "UT_PtrArray.h"
00024 #include "UT_Lock.h"
00025
00026 class UT_FixedAllocator;
00027
00028 class UT_API UT_SmallObjectAllocator
00029 {
00030 public:
00031 UT_SmallObjectAllocator(bool cleanPages,
00032 int pageSize,
00033 size_t maxObjectSize,
00034 bool threadSafe);
00035 ~UT_SmallObjectAllocator();
00036
00037 void *allocate(size_t numBytes);
00038 void deallocate(void *p, size_t size);
00039
00040 private:
00041 UT_FixedAllocator *findAllocator(size_t size);
00042
00043 private:
00044 UT_PtrArray<UT_FixedAllocator *> myPool;
00045 UT_FixedAllocator *myLastAlloc;
00046 UT_Lock myLock;
00047 size_t myPageSize;
00048 size_t myMaxObjectSize;
00049 bool myCleanPages;
00050 };
00051
00052 #endif