This class implements a memory manager that maintains a configurable number of bdlma::Pool objects, each dispensing memory blocks of a unique size. The Pool objects are placed in an array, with each successive pool managing memory blocks of size twice that of the previous pool. Each multipool allocation (deallocation) request allocates memory from (returns memory to) the internal pool having the smallest block size not less than the requested size, or, if no pool manages memory blocks of sufficient sized, from a separately managed list of memory blocks. Both the release method and the destructor of a bdema::Multipool release all memory currently allocated via the object.
See bdlma_concurrentmultipool
|
| | ConcurrentMultipool (bslma::Allocator *basicAllocator=0) |
| |
| | ConcurrentMultipool (int numPools, bslma::Allocator *basicAllocator=0) |
| |
| | ConcurrentMultipool (bsls::BlockGrowth::Strategy growthStrategy, bslma::Allocator *basicAllocator=0) |
| |
| | ConcurrentMultipool (int numPools, bsls::BlockGrowth::Strategy growthStrategy, bslma::Allocator *basicAllocator=0) |
| |
| | ConcurrentMultipool (int numPools, bsls::BlockGrowth::Strategy growthStrategy, int maxBlocksPerChunk, bslma::Allocator *basicAllocator=0) |
| |
| | ConcurrentMultipool (int numPools, const bsls::BlockGrowth::Strategy *growthStrategyArray, bslma::Allocator *basicAllocator=0) |
| |
| | ConcurrentMultipool (int numPools, const bsls::BlockGrowth::Strategy *growthStrategyArray, int maxBlocksPerChunk, bslma::Allocator *basicAllocator=0) |
| |
| | ConcurrentMultipool (int numPools, bsls::BlockGrowth::Strategy growthStrategy, const int *maxBlocksPerChunkArray, bslma::Allocator *basicAllocator=0) |
| |
| | ConcurrentMultipool (int numPools, const bsls::BlockGrowth::Strategy *growthStrategyArray, const int *maxBlocksPerChunkArray, bslma::Allocator *basicAllocator=0) |
| |
| | ~ConcurrentMultipool () |
| |
| void * | allocate (bsls::Types::size_type size) |
| |
| void | deallocate (void *address) |
| |
| template<class TYPE > |
| void | deleteObject (const TYPE *object) |
| |
| template<class TYPE > |
| void | deleteObjectRaw (const TYPE *object) |
| |
| void | release () |
| |
| void | reserveCapacity (bsls::Types::size_type size, int numBlocks) |
| |
| int | numPools () const |
| |
| bsls::Types::size_type | maxPooledBlockSize () const |
| |
| bslma::Allocator * | allocator () const |
| |
Create a multipool memory manager having the specified numPools, indicating the number of internally created Pool objects; the block size of the first pool is 8 bytes, with the block size of each additional pool successively doubling. Optionally specify a growthStrategy indicating whether the number of blocks allocated at once for every internally created Pool should be either fixed or grow geometrically, starting with 1. If growthStrategy is not specified, optionally specify growthStrategyArray, indicating the strategies for each individual Pool created by this object. If neither growthStrategy nor growthStrategyArray are specified, the allocation strategy for each internally created Pool object will grow geometrically, starting from 1. Optionally specify a maxBlocksPerChunk, indicating the maximum number of blocks to be allocated at once when a pool must be replenished. If maxBlocksPerChunk is not specified, optionally specify maxBlocksPerChunkArray, indicating the maximum number of blocks to allocate at once for each individually created Pool object. If neither maxBlocksPerChunk nor maxBlocksPerChunkArray are specified, an implementation-defined value is used. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. Memory allocation (and deallocation) requests will be satisfied using the internally maintained pool managing memory blocks of the smallest size not less than the requested size, or directly from the underlying allocator (supplied at construction), if no internally pool managing memory block of sufficient size exists.
- Precondition
- The behavior is undefined unless
1 <= numPools, growthStrategyArray has at least numPools strategies, 1 <= maxBlocksPerChunk and maxBlocksPerChunkArray have at least numPools positive values.
- Note
- Note that, on platforms where
8 < bsls::AlignmentUtil::BSLS_MAX_ALIGNMENT, excess memory may be allocated for pools managing smaller blocks. Also note that the maximum need not be an integral power of 2; if geometric growth would exceed a maximum value, the chunk size is capped at that value).