[#BloombergLP-bdlma-ConcurrentPoolAllocator] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlma.adoc[bdlma]::ConcurrentPoolAllocator :relfileprefix: ../../ :mrdocs: Thread‐safe allocator that manages pooled memory blocks of uniform size. == Synopsis Declared in `<bdlma_concurrentpoolallocator.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class ConcurrentPoolAllocator : public xref:BloombergLP/bslma/Allocator.adoc[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 [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bslma/Allocator.adoc[bslma::Allocator]` | Pure abstract protocol for clients and suppliers of raw memory. |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlma/ConcurrentPoolAllocator/size_type.adoc[`size_type`] | This `typedef` is an alias for the block size type. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlma/ConcurrentPoolAllocator/2constructor-00fc.adoc[`ConcurrentPoolAllocator`] [.small]#[constructor]# | Constructors | xref:BloombergLP/bdlma/ConcurrentPoolAllocator/2destructor.adoc[`~ConcurrentPoolAllocator`] [.small]#[destructor]# [.small]#[virtual]# | Destroy this pool allocator. | xref:BloombergLP/bslma/Allocator/operator_assign.adoc[`operator=`] | | xref:BloombergLP/bdlma/ConcurrentPoolAllocator/allocate-08.adoc[`allocate`] | Return a newly allocated block of memory of (at least) `size` bytes. | xref:BloombergLP/bdlma/ConcurrentPoolAllocator/blockSize.adoc[`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. | xref:BloombergLP/bdlma/ConcurrentPoolAllocator/deallocate-010.adoc[`deallocate`] | Return the memory at the specified `address` back to this allocator. | xref:BloombergLP/bslma/Allocator/deleteObject-09.adoc[`deleteObject`] | `deleteObject` overloads | xref:BloombergLP/bslma/Allocator/deleteObjectRaw-06f.adoc[`deleteObjectRaw`] | `deleteObjectRaw` overloads | xref:BloombergLP/bslma/Allocator/is_equal.adoc[`is_equal`] | | xref:BloombergLP/bdlma/ConcurrentPoolAllocator/release.adoc[`release`] | Relinquish all memory currently allocated through this pool allocator. | xref:BloombergLP/bdlma/ConcurrentPoolAllocator/reserveCapacity.adoc[`reserveCapacity`] | Reserve capacity for at least `numObjects` objects from this allocator. |=== == Static Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/Allocator/throwBadAlloc.adoc[`throwBadAlloc`] | Throw `std::bad_alloc` or abort the program. |=== == Protected Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/Allocator/do_allocate.adoc[`do_allocate`] [.small]#[virtual]# | Return a newly allocated block of at least `bytes` with `alignment`. | xref:BloombergLP/bslma/Allocator/do_deallocate.adoc[`do_deallocate`] [.small]#[virtual]# | Return the memory block at `p` having `bytes` and `alignment`. | xref:BloombergLP/bslma/Allocator/do_is_equal.adoc[`do_is_equal`] [.small]#[virtual]# | Return whether this allocator can exchange memory with `other`. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#