BloombergLP::bdlma::ConcurrentPoolAllocator

Thread-safe allocator that manages pooled memory blocks of uniform size.

Synopsis

Declared in <bdlma_concurrentpoolallocator.h>

class ConcurrentPoolAllocator
    : public bslma::Allocator

Description

This class implements the bslma::Allocator protocol to provide an allocator that manages pooled memory blocks of some uniform size, specified either at construction, or at the first invocation of the allocate method. This allocator maintains an internal linked list of free memory blocks, and dispenses one block for each allocate method invocation. When a memory block is deallocated, it is returned to the free list for potential reuse.

This class guarantees thread-safety while allocating or releasing memory.

Base Classes

NameDescription
bslma::AllocatorPure abstract protocol for clients and suppliers of raw memory.

Type Aliases

NameDescription
size_type This typedef is an alias for the block size type.

Member Functions

NameDescription
ConcurrentPoolAllocator [constructor]Constructors
~ConcurrentPoolAllocator [destructor] [virtual]Destroy this pool allocator.
operator=
allocate Return a newly allocated block of memory of (at least) size bytes.
blockSize Return the size (in bytes) of the memory blocks allocated from this allocator. Note that all blocks dispensed by this allocator have the same size.
deallocate Return the memory at the specified address back to this allocator.
deleteObject deleteObject overloads
deleteObjectRaw deleteObjectRaw overloads
is_equal
release Relinquish all memory currently allocated through this pool allocator.
reserveCapacity Reserve capacity for at least numObjects objects from this allocator.

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.