1 #ifndef Protium_SmallObject_h_
2 #define Protium_SmallObject_h_
25 template<
template <
class,
class>
class ThreadPolicy,
26 std::size_t chunkSize,
27 std::size_t maxSmallObjectSize,
28 std::size_t objectAlignSize,
29 template <
class>
class LifetimePolicy,
35 maxSmallObjectSize, objectAlignSize, LifetimePolicy >
ObjAllocator;
39 typedef ThreadPolicy< ObjAllocator, MutexPolicy >
ThreadType;
44 static void *
operator new ( std::size_t size )
throw ( std::bad_alloc ){
45 typename ThreadType::Lock lock;
50 static void *
operator new ( std::size_t size,
const std::nothrow_t & )
throw () {
51 typename ThreadType::Lock lock;
56 inline static void *
operator new ( std::size_t size,
void * place ) {
57 return ::operator
new( size, place );
60 static void operator delete (
void * p, std::size_t size )
throw () {
61 typename ThreadType::Lock lock;
66 static void operator delete (
void * p,
const std::nothrow_t & )
throw() {
67 typename ThreadType::Lock lock;
72 inline static void operator delete (
void * p,
void * place ) {
73 ::operator
delete ( p, place );
76 static void *
operator new [] ( std::size_t size )
throw ( std::bad_alloc ) {
77 typename ThreadType::Lock lock;
82 static void *
operator new [] ( std::size_t size,
const std::nothrow_t & )
throw () {
83 typename ThreadType::Lock lock;
88 inline static void *
operator new [] ( std::size_t size,
void * place ) {
89 return ::operator
new( size, place );
92 static void operator delete [] (
void * p, std::size_t size )
throw () {
93 typename ThreadType::Lock lock;
98 static void operator delete [] (
void * p,
const std::nothrow_t & )
throw(){
99 typename ThreadType::Lock lock;
104 inline static void operator delete [] (
void * p,
void * place ) {
105 ::operator
delete ( p, place );
125 std::size_t chunkSize = 4096,
126 std::size_t maxSmallObjectSize = 256,
127 std::size_t objectAlignSize = 4,
132 maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >
153 std::size_t chunkSize = 4096,
154 std::size_t maxSmallObjectSize = 256,
155 std::size_t objectAlignSize = 4,
159 maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >
181 #endif //Protium_SmallObject_h_
static Host & Instance()
Use to get instance.
ThreadPolicy< ObjAllocator, MutexPolicy > ThreadType
Protium::Allocation::SmallObjectAllocator< ThreadPolicy, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy > ObjAllocator
Type of allocator to host the allocator singleton.
Base class for small objects to be used in the small object allocation scheme.
ObjAllocator::AllocatorSingleton AllocatorSingleton
SmallObject & operator=(const SmallObject &)
SmallObjectBase & operator=(const SmallObjectBase &)
SmallValueObject DefaultSmallValueObject
Use to specify non-thread safe classes.
SmallObjectBase(const SmallObjectBase &)
SmallObject DefaultSmallObject
A default small obect type.
Wrapper class for pthreads-style mutexes.
SmallValueObject(const SmallValueObject &)
Singleton small object allocator.
Inherit from this in order to benefit from small object allocation.
Inherit from this in order to benefit from small object allocation.
SmallValueObject & operator=(const SmallValueObject &)