BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlcc::SharedObjectPool< TYPE, CREATOR, RESETTER > Class Template Reference

#include <bdlcc_sharedobjectpool.h>

Public Types

typedef CREATOR CreatorType
 
typedef RESETTER ResetterType
 

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (SharedObjectPool, bslma::UsesBslmaAllocator)
 
 SharedObjectPool (int growBy=-1, bslma::Allocator *basicAllocator=0)
 
 SharedObjectPool (const CREATOR &objectCreator, bslma::Allocator *basicAllocator=0)
 
 SharedObjectPool (const CREATOR &objectCreator, int growBy, bslma::Allocator *basicAllocator=0)
 
 SharedObjectPool (const CREATOR &objectCreator, const RESETTER &objectResetter, int growBy=-1, bslma::Allocator *basicAllocator=0)
 
 ~SharedObjectPool ()
 
bsl::shared_ptr< TYPE > getObject ()
 
void increaseCapacity (int growBy)
 
void reserveCapacity (int growBy)
 
int numAvailableObjects () const
 Return a snapshot of the number of objects available in this pool.
 
int numObjects () const
 

Member Typedef Documentation

◆ CreatorType

template<class TYPE , class CREATOR = ObjectPoolFunctors::DefaultCreator, class RESETTER = ObjectPoolFunctors::Nil<TYPE>>
typedef CREATOR bdlcc::SharedObjectPool< TYPE, CREATOR, RESETTER >::CreatorType

◆ ResetterType

template<class TYPE , class CREATOR = ObjectPoolFunctors::DefaultCreator, class RESETTER = ObjectPoolFunctors::Nil<TYPE>>
typedef RESETTER bdlcc::SharedObjectPool< TYPE, CREATOR, RESETTER >::ResetterType

Constructor & Destructor Documentation

◆ SharedObjectPool() [1/4]

template<class TYPE , class CREATOR , class RESETTER >
bdlcc::SharedObjectPool< TYPE, CREATOR, RESETTER >::SharedObjectPool ( int  growBy = -1,
bslma::Allocator basicAllocator = 0 
)
inlineexplicit

◆ SharedObjectPool() [2/4]

template<class TYPE , class CREATOR , class RESETTER >
bdlcc::SharedObjectPool< TYPE, CREATOR, RESETTER >::SharedObjectPool ( const CREATOR &  objectCreator,
bslma::Allocator basicAllocator = 0 
)
inlineexplicit

◆ SharedObjectPool() [3/4]

template<class TYPE , class CREATOR , class RESETTER >
bdlcc::SharedObjectPool< TYPE, CREATOR, RESETTER >::SharedObjectPool ( const CREATOR &  objectCreator,
int  growBy,
bslma::Allocator basicAllocator = 0 
)
inline

◆ SharedObjectPool() [4/4]

template<class TYPE , class CREATOR , class RESETTER >
bdlcc::SharedObjectPool< TYPE, CREATOR, RESETTER >::SharedObjectPool ( const CREATOR &  objectCreator,
const RESETTER &  objectResetter,
int  growBy = -1,
bslma::Allocator basicAllocator = 0 
)
inline

Create an object pool that dispenses shared pointers to TYPE. When the pool is depleted, it increases its capacity according to the optionally specified growBy value. If growBy is positive, the pool always increases by at least growBy. If growBy is negative, the amount of increase begins at -growBy and then grows geometrically up to an implementation-defined maximum. The optionally specified objectCreator is called whenever objects must be constructed. If objectCreator is not specified and the parameterized CREATOR is the default type (that is, ObjectPoolFunctors::DefaultCreator), a function that calls the default constructor of TYPE with placement new, passing this pools allocator if TYPE uses allocator, is used. If the parameterizedCREATORis some other type, andobjectCreatoris not specified, the default value of theCREATORtype is used. The optionally specifiedobjectResetteris invoked with a pointer to an object ofTYPEwhen the object is returned to the pool. It must reset the object into a valid state for reuse. If objectResetteris not specified, a default RESETTER object is used. Optionally specify a basic allocator to supply memory. If basicAllocatoris 0, the currently installed default allocator is used. The behavior is undefined ifgrowBy` is 0.

◆ ~SharedObjectPool()

template<class TYPE , class CREATOR , class RESETTER >
bdlcc::SharedObjectPool< TYPE, CREATOR, RESETTER >::~SharedObjectPool ( )
inline

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.

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION()

template<class TYPE , class CREATOR = ObjectPoolFunctors::DefaultCreator, class RESETTER = ObjectPoolFunctors::Nil<TYPE>>
bdlcc::SharedObjectPool< TYPE, CREATOR, RESETTER >::BSLMF_NESTED_TRAIT_DECLARATION ( SharedObjectPool< TYPE, CREATOR, RESETTER >  ,
bslma::UsesBslmaAllocator   
)

◆ getObject()

template<class TYPE , class CREATOR , class RESETTER >
bsl::shared_ptr< TYPE > bdlcc::SharedObjectPool< TYPE, CREATOR, RESETTER >::getObject ( )
inline

Return a pointer to an object from this object pool. When the last shared pointer to the object is destroyed, the object will be reset as specified at construction and then returned to the pool. If this pool is empty, it is replenished according to the strategy specified at construction.

◆ increaseCapacity()

template<class TYPE , class CREATOR , class RESETTER >
void bdlcc::SharedObjectPool< TYPE, CREATOR, RESETTER >::increaseCapacity ( int  growBy)
inline

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

◆ numAvailableObjects()

template<class TYPE , class CREATOR , class RESETTER >
int bdlcc::SharedObjectPool< TYPE, CREATOR, RESETTER >::numAvailableObjects ( ) const
inline

◆ numObjects()

template<class TYPE , class CREATOR , class RESETTER >
int bdlcc::SharedObjectPool< TYPE, CREATOR, RESETTER >::numObjects ( ) const
inline

Return the (instantaneous) number of objects managed by this pool. This includes both the objects available in the pool and the objects that were allocated from the pool and not yet released.

◆ reserveCapacity()

template<class TYPE , class CREATOR , class RESETTER >
void bdlcc::SharedObjectPool< TYPE, CREATOR, RESETTER >::reserveCapacity ( int  growBy)
inline

Create enough objects to satisfy requests for at least the specified growBy objects before the next replenishment. The behavior is undefined unless 0 <= growBy. Note that this method is different from increaseCapacity in that the number of created objects may be less than growBy.


The documentation for this class was generated from the following file: