[#BloombergLP-bdlcc-ObjectPool] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlcc.adoc[bdlcc]::ObjectPool :relfileprefix: ../../ :mrdocs: Thread‐safe pool of reusable objects that implements `bdlma::Factory`. == Synopsis Declared in `<bdlcc_objectpool.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class TYPE, class CREATOR = xref:BloombergLP/bdlcc/ObjectPoolFunctors/DefaultCreator.adoc[ObjectPoolFunctors::DefaultCreator], class RESETTER = xref:BloombergLP/bdlcc/ObjectPoolFunctors/Nil.adoc[ObjectPoolFunctors::Nil<TYPE>]> class ObjectPool : public xref:BloombergLP/bdlma/Factory.adoc[bdlma::Factory<TYPE>] ---- == Description This class provides a thread‐safe pool of reusable objects. It also implements the `bdlma::Factory` protocol: "creating" objects gets them from the pool and "deleting" objects returns them to the pool. == Base Classes [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bdlma/Factory.adoc[bdlma::Factory<TYPE>]` | Provide a protocol for a thread‐safe object creator and deleter. |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlcc/ObjectPool/CreatorType.adoc[`CreatorType`] | Type of the creator functor used by this pool. | xref:BloombergLP/bdlcc/ObjectPool/ResetterType.adoc[`ResetterType`] | Type of the resetter functor used by this pool. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlcc/ObjectPool/2constructor-04.adoc[`ObjectPool`] [.small]#[constructor]# | Constructors | xref:BloombergLP/bdlcc/ObjectPool/2destructor.adoc[`~ObjectPool`] [.small]#[destructor]# [.small]#[virtual]# | Destroy this object pool. All objects created by this pool are destroyed (even if some of them are still in use) and memory is reclaimed. | xref:BloombergLP/bdlcc/ObjectPool/createObject.adoc[`createObject`] [.small]#[virtual]# | This concrete implementation of `bdlma::Factory::createObject` invokes `getObject`. This should not be invoked directly. | xref:BloombergLP/bdlcc/ObjectPool/deleteObject-03.adoc[`deleteObject`] | `deleteObject` overloads | xref:BloombergLP/bdlcc/ObjectPool/getObject.adoc[`getObject`] | Return a modifiable object from this object pool. | xref:BloombergLP/bdlcc/ObjectPool/increaseCapacity.adoc[`increaseCapacity`] | Create the specified `numObjects` objects and add them to this object pool. The behavior is undefined unless `0 <= numObjects`. | xref:BloombergLP/bdlcc/ObjectPool/numAvailableObjects.adoc[`numAvailableObjects`] | Return a _snapshot_ of the number of objects available in this pool. | xref:BloombergLP/bdlcc/ObjectPool/numObjects.adoc[`numObjects`] | Return the number of objects currently managed by this pool. | xref:BloombergLP/bdlcc/ObjectPool/releaseObject.adoc[`releaseObject`] | Return the specified `object` back to this object pool. | xref:BloombergLP/bdlcc/ObjectPool/reserveCapacity.adoc[`reserveCapacity`] | Ensure this pool can satisfy at least `numObjects` requests. | xref:BloombergLP/bdlcc/ObjectPool/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<ObjectPool, UsesBslmaAllocator>`] | Declare that this type uses a `bslma` allocator. |=== == Friends [cols="1,4"] |=== | Name| Description | `BloombergLP::bdlcc::ObjectPool::AutoCleanup` | |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#