1 #ifndef FWCore_Utilities_ReusableObjectHolder_h 2 #define FWCore_Utilities_ReusableObjectHolder_h 72 #include "tbb/concurrent_queue.h" 83 assert(0== iOther.m_outstandingObjects);
96 void add(std::unique_ptr<T> iItem){
109 return std::shared_ptr<T>{};
114 return std::shared_ptr<T>{item, [pHolder](
T* iItem) {pHolder->addBack(iItem);} };
118 template<
typename F>
120 std::shared_ptr<T> returnValue;
121 while ( ! ( returnValue =
tryToGet()) ) {
122 add( std::unique_ptr<T>(iFunc()) );
130 template<
typename FM,
typename FC>
132 std::shared_ptr<T> returnValue;
133 while ( ! ( returnValue =
tryToGet()) ) {
134 add( std::unique_ptr<T>(iMakeFunc()) );
136 iClearFunc(returnValue.get());
tbb::concurrent_queue< T * > m_availableQueue
std::shared_ptr< T > makeOrGet(F iFunc)
If there isn't an object already available, creates a new one using iFunc.
std::shared_ptr< T > makeOrGetAndClear(FM iMakeFunc, FC iClearFunc)
void add(std::unique_ptr< T > iItem)
ReusableObjectHolder(ReusableObjectHolder &&iOther)
std::shared_ptr< T > tryToGet()
std::atomic< size_t > m_outstandingObjects
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)