ROSE  0.11.96.11
SmallObject.h
1 // WARNING: Changes to this file must be contributed back to Sawyer or else they will
2 // be clobbered by the next update from Sawyer. The Sawyer repository is at
3 // https://github.com/matzke1/sawyer.
4 
5 
6 
7 
8 #ifndef Sawyer_SmallObject_H
9 #define Sawyer_SmallObject_H
10 
11 #include <Sawyer/PoolAllocator.h>
12 #include <Sawyer/Sawyer.h>
13 
14 namespace Sawyer {
15 
19 class SAWYER_EXPORT SmallObject {
20 #include <Sawyer/WarningsOff.h>
21  static SynchronizedPoolAllocator allocator_;
22 #include <Sawyer/WarningsRestore.h>
23 public:
25  static SynchronizedPoolAllocator& poolAllocator() { return allocator_; }
26 
27  static void *operator new(size_t size) { return allocator_.allocate(size); }
28  static void operator delete(void *ptr, size_t size) { allocator_.deallocate(ptr, size); }
29 };
30 
31 } // namespace
32 #endif
Sawyer::SmallObject::poolAllocator
static SynchronizedPoolAllocator & poolAllocator()
Return the pool allocator for this class.
Definition: SmallObject.h:25
Sawyer::SmallObject
Small object support.
Definition: SmallObject.h:19
Sawyer
Name space for the entire library.
Definition: Access.h:13
Sawyer::PoolAllocatorBase::allocate
void * allocate(size_t size)
Allocate one object of specified size.
Definition: PoolAllocator.h:422
Sawyer::PoolAllocatorBase
Small object allocation from memory pools.
Definition: PoolAllocator.h:60