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 = ::Loki::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.

Definition at line 222 of file SmallObj.h.


Member Function Documentation

template<template< class, class > class T, std::size_t C, std::size_t M, std::size_t O, template< class > class L, class X>
void Loki::AllocatorSingleton< T, C, M, O, L, X >::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.

Definition at line 287 of file SmallObj.h.

References Loki::AllocatorSingleton< ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >::Instance(), and Loki::SmallObjAllocator::TrimExcessMemory().

Here is the call graph for this function:

template<template< class, class > class T, std::size_t C, std::size_t M, std::size_t O, template< class > class L, class X>
bool Loki::AllocatorSingleton< T, C, M, O, L, X >::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.

Definition at line 303 of file SmallObj.h.

References Loki::AllocatorSingleton< ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >::Instance(), and Loki::SmallObjAllocator::IsCorrupt().

Here is the call graph for this function:


The documentation for this class was generated from the following file:
Generated on Sun Feb 25 16:52:46 2007 for Loki by  doxygen 1.5.1-p1