BloombergLP::bdlma::ConcurrentMultipoolAllocator

Thread-safe allocator managing pools of varying block sizes.

Synopsis

Declared in <bdlma_concurrentmultipoolallocator.h>

class ConcurrentMultipoolAllocator
    : public bdlma::ManagedAllocator

Description

This class implements the bdlma::ManagedAllocator protocol to provide a thread-safe allocator that maintains a configurable number of 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 ConcurrentMultipoolAllocator release all memory currently allocated via the object.

Base Classes

NameDescription
bdlma::ManagedAllocatorProtocol for allocators that support releasing all allocated memory.

Type Aliases

NameDescription
size_type Alias for an unsigned integral type capable of representing the number of bytes in this platform's virtual address space.

Member Functions

NameDescription
ConcurrentMultipoolAllocator [constructor]Constructors
~ConcurrentMultipoolAllocator [destructor] [virtual]Destroy this multipool allocator. All memory allocated from this allocator is released.
operator=
allocate allocate overloads
deallocate Return the memory block at address to this allocator for reuse.
deleteObject deleteObject overloads
deleteObjectRaw deleteObjectRaw overloads
is_equal
maxPooledBlockSize Return the maximum size of memory blocks pooled by this allocator.
numPools Return the number of pools managed by this multipool allocator.
release [virtual]Relinquish all memory currently allocated through this multipool allocator.
reserveCapacity Reserve capacity for at least numObjects objects of size bytes.

Static Member Functions

NameDescription
throwBadAlloc Throw std::bad_alloc or abort the program.

Protected Member Functions

NameDescription
do_allocate [virtual]Return a newly allocated block of at least bytes with alignment.
do_deallocate [virtual]Return the memory block at p having bytes and alignment.
do_is_equal [virtual]Return whether this allocator can exchange memory with other.