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.

Synopsis

Declared in <bdlma_concurrentmultipool.h>

class ConcurrentMultipool;

Member Functions

Name

Description

ConcurrentMultipool [constructor]

Constructors

~ConcurrentMultipool [destructor]

Destroy this multipool. All memory allocated from this memory pool is released.

allocate

Return the address of a contiguous block of maximally‐aligned memory of (at least) the specified size (in bytes). If size > maxPooledBlockSize(), the memory allocation is managed directly by the underlying allocator, and will not be pooled, but will be deallocated when the release method is called, or when this object is destroyed. If size is 0, no memory is allocated and 0 is returned.

allocator

Return the allocator used by this object to allocate memory. Note that this allocator can not be used to deallocate memory allocated through this pool.

deallocate

Relinquish the memory block at the specified address back to this multipool object for reuse. The behavior is undefined unless address is non‐zero, was allocated by this multipool object, and has not already been deallocated.

deleteObject

Destroy the specified object based on its dynamic type and then use this multipool object to deallocate its memory footprint. This method has no effect if object is 0. The behavior is undefined unless object, when cast appropriately to void *, was allocated using this multipool object and has not already been deallocated. Note that dynamic_cast<void *>(object) is applied if TYPE is polymorphic, and static_cast<void *>(object) is applied otherwise.

deleteObjectRaw

Destroy the specified object and then use this multipool to deallocate its memory footprint. This method has no effect if object is 0. The behavior is undefined unless object is not a secondary base class pointer (i.e., the address is (numerically) the same as when it was originally dispensed by this multipool), was allocated using this multipool, and has not already been deallocated.

maxPooledBlockSize

Return the maximum size of memory blocks that are pooled by this multipool object. Note that the maximum value is defined as: ` 2 ˆ (numPools + 2) ` where numPools is either specified at construction, or an implementation‐defined value.

numPools

Return the number of pools managed by this multipool object.

release

Relinquish all memory currently allocated via this multipool object.

reserveCapacity

Reserve memory from this multipool to satisfy memory requests for at least the specified numBlocks having the specified size (in bytes) before the pool replenishes. If size is 0, this method has no effect. The behavior is undefined unless size <= maxPooledBlockSize() and 0 <= numBlocks.

Created with MrDocs