8#ifndef INCLUDED_BDLCC_SHAREDOBJECTPOOL
9#define INCLUDED_BDLCC_SHAREDOBJECTPOOL
256#include <bdlscm_version.h>
276#include <bsl_memory.h>
285template <
class TYPE,
class RESETTER>
314 template <
class CREATOR>
316 CREATOR* objectCreator,
435 const RESETTER& objectResetter,
485template <
class TYPE,
class RESETTER>
486template <
class CREATOR>
489 CREATOR* objectCreator,
493: d_objectResetter(objectResetter,basicAllocator)
496 (*objectCreator)(d_instance.buffer(), basicAllocator);
499template <
class TYPE,
class RESETTER>
503 d_instance.object().~TYPE();
507template <
class TYPE,
class RESETTER>
511 d_objectResetter.object()(&d_instance.object());
514template <
class TYPE,
class RESETTER>
518 d_pool_p->releaseObject(
this);
521template <
class TYPE,
class RESETTER>
524 const std::type_info& )
529template <
class TYPE,
class RESETTER>
537template <
class TYPE,
class RESETTER>
541 return const_cast<void*
>(
static_cast<const void*
>(d_instance.buffer()));
544template <
class TYPE,
class RESETTER>
548 return &d_instance.object();
556template <
class TYPE,
class CREATOR,
class RESETTER>
562 RepType *r =
new (memory) RepType(&d_objectCreator.object(),
566 r->resetCountsRaw(0, 0);
572#if defined(BSLS_PLATFORM_CMP_MSVC)
578#pragma warning(disable : 4355)
583template <
class TYPE,
class CREATOR,
class RESETTER>
586 const CREATOR& objectCreator,
587 const RESETTER& objectResetter,
590: d_objectCreator(objectCreator,basicAllocator)
591, d_objectResetter(objectResetter,basicAllocator)
592, d_pool(
bdlf::BindUtil::bind(&
MyType::constructRepObject, this,
593 bdlf::PlaceHolders::_1,
594 bdlf::PlaceHolders::_2),
595 growBy, basicAllocator)
599template <
class TYPE,
class CREATOR,
class RESETTER>
604: d_objectCreator(basicAllocator)
605, d_objectResetter(basicAllocator)
606, d_pool(
bdlf::BindUtil::bind(&
MyType::constructRepObject, this,
607 bdlf::PlaceHolders::_1,
608 bdlf::PlaceHolders::_2),
609 growBy, basicAllocator)
613template <
class TYPE,
class CREATOR,
class RESETTER>
616 const CREATOR& objectCreator,
619: d_objectCreator(objectCreator, basicAllocator)
620, d_objectResetter(basicAllocator)
621, d_pool(
bdlf::BindUtil::bind(&
MyType::constructRepObject, this,
622 bdlf::PlaceHolders::_1,
623 bdlf::PlaceHolders::_2),
624 growBy, basicAllocator)
628template <
class TYPE,
class CREATOR,
class RESETTER>
631 const CREATOR& objectCreator,
633: d_objectCreator(objectCreator, basicAllocator)
634, d_objectResetter(basicAllocator)
635, d_pool(
bdlf::BindUtil::bind(&
MyType::constructRepObject, this,
636 bdlf::PlaceHolders::_1,
637 bdlf::PlaceHolders::_2),
643#if defined(BSLS_PLATFORM_CMP_MSVC)
650template <
class TYPE,
class CREATOR,
class RESETTER>
657template <
class TYPE,
class CREATOR,
class RESETTER>
662 RepType *rep = d_pool.getObject();
669template <
class TYPE,
class CREATOR,
class RESETTER>
674 d_pool.increaseCapacity(growBy);
677template <
class TYPE,
class CREATOR,
class RESETTER>
682 d_pool.reserveCapacity(growBy);
686template <
class TYPE,
class CREATOR,
class RESETTER>
690 return d_pool.numAvailableObjects();
693template <
class TYPE,
class CREATOR,
class RESETTER>
697 return d_pool.numObjects();
Definition bdlcc_objectpool.h:428
Definition bdlcc_objectpool.h:444
Definition bdlcc_objectpool.h:686
Definition bdlcc_sharedobjectpool.h:286
void reset()
Definition bdlcc_sharedobjectpool.h:509
void * originalPtr() const BSLS_KEYWORD_OVERRIDE
Definition bdlcc_sharedobjectpool.h:539
TYPE * ptr()
Return a pointer to the in-place object.
Definition bdlcc_sharedobjectpool.h:546
void disposeObject() BSLS_KEYWORD_OVERRIDE
Definition bdlcc_sharedobjectpool.h:531
~SharedObjectPool_Rep() BSLS_KEYWORD_OVERRIDE
Definition bdlcc_sharedobjectpool.h:501
void * getDeleter(const std::type_info &type) BSLS_KEYWORD_OVERRIDE
Definition bdlcc_sharedobjectpool.h:523
void disposeRep() BSLS_KEYWORD_OVERRIDE
Definition bdlcc_sharedobjectpool.h:516
Definition bdlcc_sharedobjectpool.h:366
void reserveCapacity(int growBy)
Definition bdlcc_sharedobjectpool.h:680
CREATOR CreatorType
Definition bdlcc_sharedobjectpool.h:393
void increaseCapacity(int growBy)
Definition bdlcc_sharedobjectpool.h:672
~SharedObjectPool()
Definition bdlcc_sharedobjectpool.h:652
RESETTER ResetterType
Definition bdlcc_sharedobjectpool.h:394
SharedObjectPool(const CREATOR &objectCreator, const RESETTER &objectResetter, int growBy=-1, bslma::Allocator *basicAllocator=0)
Definition bdlcc_sharedobjectpool.h:585
BSLMF_NESTED_TRAIT_DECLARATION(SharedObjectPool, bslma::UsesBslmaAllocator)
SharedObjectPool(const CREATOR &objectCreator, bslma::Allocator *basicAllocator=0)
Definition bdlcc_sharedobjectpool.h:630
SharedObjectPool(const CREATOR &objectCreator, int growBy, bslma::Allocator *basicAllocator=0)
Definition bdlcc_sharedobjectpool.h:615
bsl::shared_ptr< TYPE > getObject()
Definition bdlcc_sharedobjectpool.h:660
SharedObjectPool(int growBy=-1, bslma::Allocator *basicAllocator=0)
Definition bdlcc_sharedobjectpool.h:601
int numObjects() const
Definition bdlcc_sharedobjectpool.h:695
int numAvailableObjects() const
Return a snapshot of the number of objects available in this pool.
Definition bdlcc_sharedobjectpool.h:688
Definition bslstl_sharedptr.h:1830
Definition bslalg_constructorproxy.h:368
Definition bslma_allocator.h:457
Definition bslma_sharedptrrep.h:338
void resetCountsRaw(int numSharedReferences, int numWeakReferences)
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_OVERRIDE
Definition bsls_keyword.h:653
Definition bdlcc_boundedqueue.h:270
Definition bdlf_bind.h:976
bsl::function< void(void *, bslma::Allocator *)> DefaultCreator
Definition bdlcc_objectpool.h:419
Definition bdlcc_objectpool.h:655
Definition bslma_usesbslmaallocator.h:343
Definition bsls_objectbuffer.h:276