Loki
0.1.7
|
#include <SmallObj.h>
Public Types | |
typedef AllocatorSingleton < ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy > | MyAllocator |
Defines type of allocator. | |
typedef ThreadingModel < MyAllocator, MutexPolicy > | MyThreadingModel |
Defines type for thread-safety locking mechanism. | |
typedef Loki::SingletonHolder < MyAllocator, Loki::CreateStatic, LifetimePolicy, ThreadingModel > | MyAllocatorSingleton |
Defines singleton made from allocator. | |
Public Member Functions | |
AllocatorSingleton () | |
The default constructor is not meant to be called directly. | |
~AllocatorSingleton (void) | |
The destructor is not meant to be called directly. | |
![]() | |
void * | Allocate (std::size_t size, bool doThrow) |
void | Deallocate (void *p, std::size_t size) |
void | Deallocate (void *p) |
std::size_t | GetMaxObjectSize () const |
Returns max # of bytes which this can allocate. | |
std::size_t | GetAlignment () const |
Returns # of bytes between allocation boundaries. | |
bool | TrimExcessMemory (void) |
bool | IsCorrupt (void) const |
Static Public Member Functions | |
static AllocatorSingleton & | Instance (void) |
Returns reference to the singleton. | |
static void | ClearExtraMemory (void) |
static bool | IsCorrupted (void) |
Additional Inherited Members | |
![]() | |
SmallObjAllocator (std::size_t pageSize, std::size_t maxObjectSize, std::size_t objectAlignSize) | |
~SmallObjAllocator (void) | |
This template class is derived from SmallObjAllocator in order to pass template arguments into it, and still have a default constructor for the singleton. Each instance is a unique combination of all the template parameters, and hence is singleton only with respect to those parameters. The template parameters have default values and the class has typedefs identical to both SmallObject and SmallValueObject so that this class can be used directly instead of going through SmallObject or SmallValueObject. That design feature allows clients to use the new_handler without having the name of the new_handler function show up in classes derived from SmallObject or SmallValueObject. Thus, the only functions in the allocator which show up in SmallObject or SmallValueObject inheritance hierarchies are the new and delete operators.
|
static |
Clears any excess memory used by the allocator. Complexity is O(F + C) where F is the count of FixedAllocator's in the pool, and C is the number of Chunks in all FixedAllocator's. This never throws.
|
static |
Returns true if anything in implementation is corrupt. Complexity is O(F + C + B) where F is the count of FixedAllocator's in the pool, C is the number of Chunks in all FixedAllocator's, and B is the number of blocks in all Chunks. If it determines any data is corrupted, this will return true in release version, but assert in debug version at the line where it detects the corrupted data. If it does not detect any corrupted data, it returns false.