Loki::AllocatorSingleton< ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy > Class Template Reference
[Internals]

#include <SmallObj.h>

Inheritance diagram for Loki::AllocatorSingleton< ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >:

[legend]
Collaboration diagram for Loki::AllocatorSingleton< ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >:
[legend]
List of all members.

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.

Static Public Member Functions

static AllocatorSingletonInstance (void)
 Returns reference to the singleton.
static void ClearExtraMemory (void)
static bool IsCorrupted (void)

Detailed Description

template<template< class, class > class ThreadingModel = ::Loki::SingleThreaded, std::size_t chunkSize = 4096, std::size_t maxSmallObjectSize = 256, std::size_t objectAlignSize = 4, template< class > class LifetimePolicy = LongevityLifetime::DieAsSmallObjectParent, class MutexPolicy = ::Loki::Mutex>
class Loki::AllocatorSingleton< ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >

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.


Member Function Documentation

template<template< class, class > class TM, std::size_t CS, std::size_t MSOS, std::size_t OAS, template< class > class LP, class MX>
void Loki::AllocatorSingleton< TM, CS, MSOS, OAS, LP, MX >::ClearExtraMemory ( void   )  [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.

Note:
This function can be used as a new_handler when Loki and other memory allocators can no longer allocate. Although the C++ Standard allows new_handler functions to terminate the program when they can not release any memory, this will not do so.

template<template< class, class > class TM, std::size_t CS, std::size_t MSOS, std::size_t OAS, template< class > class LP, class MX>
bool Loki::AllocatorSingleton< TM, CS, MSOS, OAS, LP, MX >::IsCorrupted ( void   )  [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.


The documentation for this class was generated from the following file:
Generated on Mon Jun 19 15:14:44 2006 for Loki by  doxygen 1.4.7