[#BloombergLP-bdlma-ConcurrentPoolAllocator]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlma.adoc[bdlma]::ConcurrentPoolAllocator
:relfileprefix: ../../
:mrdocs:

Thread&hyphen;safe allocator that manages pooled memory blocks of uniform size&period;

== Synopsis

Declared in `&lt;bdlma&lowbar;concurrentpoolallocator&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class ConcurrentPoolAllocator
    : public xref:BloombergLP/bslma/Allocator.adoc[bslma::Allocator]
----

== Description

This class implements the `bslma&colon;&colon;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&period; This allocator maintains an internal linked list of free memory blocks, and dispenses one block for each `allocate` method invocation&period; When a memory block is deallocated, it is returned to the free list for potential reuse&period;

This class guarantees thread&hyphen;safety while allocating or releasing memory&period;

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/bslma/Allocator.adoc[bslma::Allocator]`
| Pure abstract protocol for clients and suppliers of raw memory&period;
|===

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlma/ConcurrentPoolAllocator/size_type.adoc[`size&lowbar;type`] 
| This `typedef` is an alias for the block size type&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlma/ConcurrentPoolAllocator/2constructor-00fc.adoc[`ConcurrentPoolAllocator`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bdlma/ConcurrentPoolAllocator/2destructor.adoc[`&#126;ConcurrentPoolAllocator`] [.small]#[destructor]# [.small]#[virtual]#
| Destroy this pool allocator&period;
| xref:BloombergLP/bslma/Allocator/operator_assign.adoc[`operator&equals;`] 
| 
| xref:BloombergLP/bdlma/ConcurrentPoolAllocator/allocate-08.adoc[`allocate`] 
| Return a newly allocated block of memory of (at least) `size` bytes&period;
| xref:BloombergLP/bdlma/ConcurrentPoolAllocator/blockSize.adoc[`blockSize`] 
| Return the size (in bytes) of the memory blocks allocated from this allocator&period; Note that all blocks dispensed by this allocator have the same size&period;
| xref:BloombergLP/bdlma/ConcurrentPoolAllocator/deallocate-010.adoc[`deallocate`] 
| Return the memory at the specified `address` back to this allocator&period;
| 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&lowbar;equal`] 
| 
| xref:BloombergLP/bdlma/ConcurrentPoolAllocator/release.adoc[`release`] 
| Relinquish all memory currently allocated through this pool allocator&period;
| xref:BloombergLP/bdlma/ConcurrentPoolAllocator/reserveCapacity.adoc[`reserveCapacity`] 
| Reserve capacity for at least `numObjects` objects from this allocator&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/Allocator/throwBadAlloc.adoc[`throwBadAlloc`] 
| Throw `std&colon;&colon;bad&lowbar;alloc` or abort the program&period;
|===


== Protected Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/Allocator/do_allocate.adoc[`do&lowbar;allocate`]  [.small]#[virtual]#
| Return a newly allocated block of at least `bytes` with `alignment`&period;
| xref:BloombergLP/bslma/Allocator/do_deallocate.adoc[`do&lowbar;deallocate`]  [.small]#[virtual]#
| Return the memory block at `p` having `bytes` and `alignment`&period;
| xref:BloombergLP/bslma/Allocator/do_is_equal.adoc[`do&lowbar;is&lowbar;equal`]  [.small]#[virtual]#
| Return whether this allocator can exchange memory with `other`&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
