Thread‐safe pool of reusable objects that implements bdlma::Factory.

Synopsis

Declared in <bdlcc_objectpool.h>

template<
    class TYPE,
    class CREATOR = ObjectPoolFunctors::DefaultCreator,
    class RESETTER = ObjectPoolFunctors::Nil<TYPE>>
class ObjectPool
    : public 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

Name

Description

bdlma::Factory<TYPE>

Provide a protocol for a thread‐safe object creator and deleter.

Type Aliases

Name

Description

CreatorType

Type of the creator functor used by this pool.

ResetterType

Type of the resetter functor used by this pool.

Member Functions

Name

Description

ObjectPool [constructor]

Constructors

~ObjectPool [destructor] [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.

createObject [virtual]

This concrete implementation of bdlma::Factory::createObject invokes getObject. This should not be invoked directly.

deleteObject

deleteObject overloads

getObject

Return a modifiable object from this object pool.

increaseCapacity

Create the specified numObjects objects and add them to this object pool. The behavior is undefined unless 0 <= numObjects.

numAvailableObjects

Return a snapshot of the number of objects available in this pool.

numObjects

Return the number of objects currently managed by this pool.

releaseObject

Return the specified object back to this object pool.

reserveCapacity

Ensure this pool can satisfy at least numObjects requests.

operator BloombergLP::bslmf::NestedTraitDeclaration<ObjectPool, UsesBslmaAllocator>

Declare that this type uses a bslma allocator.

Friends

Name

Description

BloombergLP::bdlcc::ObjectPool::AutoCleanup

Created with MrDocs