BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlcc_sharedobjectpool.h
Go to the documentation of this file.
1/// @file bdlcc_sharedobjectpool.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlcc_sharedobjectpool.h -*-C++-*-
8#ifndef INCLUDED_BDLCC_SHAREDOBJECTPOOL
9#define INCLUDED_BDLCC_SHAREDOBJECTPOOL
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bdlcc_sharedobjectpool bdlcc_sharedobjectpool
15/// @brief Provide a thread-safe pool of shared objects.
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlcc
19/// @{
20/// @addtogroup bdlcc_sharedobjectpool
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlcc_sharedobjectpool-purpose"> Purpose</a>
25/// * <a href="#bdlcc_sharedobjectpool-classes"> Classes </a>
26/// * <a href="#bdlcc_sharedobjectpool-description"> Description </a>
27/// * <a href="#bdlcc_sharedobjectpool-object-construction-and-destruction"> Object Construction and Destruction </a>
28/// * <a href="#bdlcc_sharedobjectpool-creator-and-resetter-template-contract"> Creator and Resetter Template Contract </a>
29/// * <a href="#bdlcc_sharedobjectpool-exception-safety"> Exception Safety </a>
30/// * <a href="#bdlcc_sharedobjectpool-pool-replenishment-policy"> Pool Replenishment Policy </a>
31/// * <a href="#bdlcc_sharedobjectpool-usage"> Usage </a>
32///
33/// # Purpose {#bdlcc_sharedobjectpool-purpose}
34/// Provide a thread-safe pool of shared objects.
35///
36/// # Classes {#bdlcc_sharedobjectpool-classes}
37///
38/// - bdlcc::SharedObjectPool: thread-enabled container of shared objects
39///
40/// @see bslstl_sharedptr
41///
42/// # Description {#bdlcc_sharedobjectpool-description}
43/// This component provides a generic thread-safe pool of shared
44/// objects, `bdlcc::SharedObjectPool`, using the acquire-release idiom. The
45/// functionality provided is identical to `bdlcc::ObjectPool`, except that
46/// `getObject` returns efficiently-constructed `bsl::shared_ptr` objects
47/// instead of raw pointers. For client code that needs to provide shared
48/// access to objects in the pool, this functionality saves an additional
49/// allocation for the shared pointer itself. Since the shared pointer and the
50/// object are contiguous in memory, this component also tends to improve
51/// performance by reducing "cache misses."
52///
53/// ## Object Construction and Destruction {#bdlcc_sharedobjectpool-object-construction-and-destruction}
54///
55///
56/// The object pool owns the memory required to store the pooled objects and the
57/// shared-pointer representations, and manages the construction, resetting, and
58/// destruction of objects. The user may supply functors to create objects and
59/// to reset them to a valid state for their return to the pool; alternatively,
60/// this component supplies reasonable defaults. Upon destruction the object
61/// pool deallocates all memory associated with the objects in the pool. The
62/// behavior is undefined if there are any outstanding shared pointer references
63/// to the objects in the pool when it is destroyed.
64///
65/// ## Creator and Resetter Template Contract {#bdlcc_sharedobjectpool-creator-and-resetter-template-contract}
66///
67///
68/// `bdlcc::SharedObjectPool` is templated on two types `CREATOR` and `RESETTER`
69/// in addition to the underlying object `TYPE`. Objects of these types may be
70/// provided at construction (or defaults may be used). The creator will be
71/// invoked as: `void(*)(void*, bslma::Allocator*)`. The resetter will be
72/// invoked as: `void(*)(TYPE*)`. The creator functor will be called to
73/// construct a new object of the parameterized `TYPE` when the pool must be
74/// expanded (and thus it will typically invoke placement new and pass its
75/// allocator argument to the constructor of `TYPE`). The resetter functor will
76/// be called before each object is returned to the pool, and is required to put
77/// the object into a state such that it is ready to be reused. The defaults
78/// for these types are as follows:
79/// @code
80/// CREATOR = bdlcc::ObjectPoolFunctors::DefaultCreator
81/// RESETTER = bdlcc::ObjectPoolFunctors::Nil<TYPE>
82/// @endcode
83/// `bdlcc::ObjectPoolFunctors::Nil` is a no-op; it is only suitable if the
84/// objects stored in the pool are *always* in a valid state to be reused.
85/// Otherwise - that is, if anything must be done to render the objects ready
86/// for reuse - another kind of `RESETTER` should be provided (so long as that
87/// type supplies `void(*)(TYPE*)`). In `bdlcc::ObjectPoolFunctors`, the
88/// classes `Clear`, `RemoveAll`, and `Reset` are all acceptable types for
89/// `RESETTER`. Since these "functor" types are fully inline, it is generally
90/// most efficient to define `reset()` (or `clear()` or `removeAll()`) in the
91/// underlying `TYPE` and allow the functor to call that method. The `CREATOR`
92/// functor defaults to an object that invokes the default constructor with
93/// placement new, passing the allocator argument if the type traits of the
94/// object indicate it uses an allocator (see @ref bslma_usesbslmaallocator ). If a
95/// custom creator functor or a custom `CREATOR` type is specified, it is the
96/// user's responsibility to ensure that it correctly passes its allocator
97/// argument through to the constructor of `TYPE` if `TYPE` uses allocator.
98///
99/// ## Exception Safety {#bdlcc_sharedobjectpool-exception-safety}
100///
101///
102/// There are two potential sources of exceptions in this component: memory
103/// allocation and object construction. The object pool is exception-neutral
104/// with full guarantee of rollback for the following methods: if an exception
105/// is thrown in `getObject`, `reserveCapacity`, or `increaseCapacity`, then the
106/// pool is in a valid unmodified state (i.e., identical to prior the call to
107/// `getObject`). No other method of `bdlcc::SharedObjectPool` can throw.
108///
109/// ## Pool Replenishment Policy {#bdlcc_sharedobjectpool-pool-replenishment-policy}
110///
111///
112/// The `growBy` parameter can be specified in the pool's constructor to
113/// instruct the pool how it is to increase its capacity each time the pool is
114/// depleted. If `growBy` is positive, the pool always replenishes itself with
115/// enough objects so that it can satisfy at least `growBy` object requests
116/// before the next replenishment. If `growBy` is negative, the pool will
117/// increase its capacity geometrically until it exceeds the internal maximum
118/// (which itself is implementation-defined), and after that it will be
119/// replenished with constant number of objects. If `growBy` is not specified,
120/// an implementation-defined default will be chosen. The behavior is undefined
121/// if growBy is 0.
122///
123/// ## Usage {#bdlcc_sharedobjectpool-usage}
124///
125///
126/// This component is intended to improve the efficiency of code which provides
127/// shared pointers to pooled objects. As an example, consider a class which
128/// maintains a pool of `vector<char>` objects and provides shared pointers to
129/// them. Using `bdlcc::ObjectPool`, the class might be implemented like this:
130/// @code
131/// typedef vector<char> CharArray;
132///
133/// class SlowCharArrayPool {
134/// bdlma::ConcurrentPoolAllocator d_spAllocator; // alloc. shared pointer
135/// bdlcc::ObjectPool<CharArray> d_charArrayPool; // supply charArrays
136///
137/// static void createCharArray(void *address, bslma::Allocator *allocator)
138/// {
139/// new (address) CharArray(allocator);
140/// }
141///
142/// static void resetAndReturnCharArray(
143/// CharArray *charArray,
144/// bdlcc::ObjectPool<CharArray> *pool)
145/// {
146/// charArray->clear();
147/// pool->releaseObject(charArray);
148/// }
149///
150/// private:
151/// // Not implemented:
152/// SlowCharArrayPool(const SlowCharArrayPool&);
153///
154/// public:
155/// SlowCharArrayPool(bslma::Allocator *basicAllocator = 0)
156/// : d_spAllocator(basicAllocator)
157/// , d_charArrayPool(bdlf::BindUtil::bind(
158/// &SlowCharArrayPool::createCharArray,
159/// bdlf::PlaceHolders::_1,
160/// basicAllocator),
161/// -1,
162/// basicAllocator)
163/// {
164/// }
165///
166/// void getCharArray(bsl::shared_ptr<CharArray> *charArray_sp)
167/// {
168/// charArray_sp->reset(d_charArrayPool.getObject(),
169/// bdlf::BindUtil::bind(
170/// &SlowCharArrayPool::resetAndReturnCharArray,
171/// bdlf::PlaceHolders::_1,
172/// &d_charArrayPool),
173/// &d_spAllocator);
174/// }
175/// };
176/// @endcode
177/// Note that `SlowCharArrayPool` must allocate the shared pointer itself from
178/// its `d_spAllocator` in addition to allocating the charArray from its pool.
179/// Moreover, note that since the same function will handle resetting the object
180/// and returning it to the pool, we must define a special function for that
181/// purpose and bind its arguments.
182///
183/// We can solve both of these issues by using `bdlcc::SharedObjectPool`
184/// instead:
185/// @code
186/// class FastCharArrayPool {
187/// typedef bdlcc::SharedObjectPool<
188/// CharArray,
189/// bdlcc::ObjectPoolFunctors::DefaultCreator,
190/// bdlcc::ObjectPoolFunctors::Clear<CharArray> > CharArrayPool;
191///
192/// CharArrayPool d_charArrayPool; // supply charArrays
193///
194/// static void createCharArray(void *address, bslma::Allocator *allocator)
195/// {
196/// new (address) CharArray(allocator);
197/// }
198///
199/// private:
200/// // Not implemented:
201/// FastCharArrayPool(const FastCharArrayPool&);
202///
203/// public:
204/// FastCharArrayPool(bslma::Allocator *basicAllocator = 0)
205/// : d_charArrayPool(bdlf::BindUtil::bind(
206/// &FastCharArrayPool::createCharArray,
207/// bdlf::PlaceHolders::_1,
208/// bdlf::PlaceHolders::_2),
209/// -1,
210/// basicAllocator)
211/// {
212/// }
213///
214/// void getCharArray(bsl::shared_ptr<CharArray> *charArray_sp)
215/// {
216/// *charArray_sp = d_charArrayPool.getObject();
217/// }
218/// };
219/// @endcode
220/// Now the shared pointer and the object are allocated as one unit from the
221/// same allocator. In addition, the resetter method is a fully-inlined class
222/// that is only responsible for resetting the object, improving efficiency and
223/// simplifying the design. We can verify that use of `bdlcc::SharedObjectPool`
224/// reduces the number of allocation requests:
225/// @code
226/// bslma::TestAllocator slowAllocator, fastAllocator;
227/// {
228/// SlowCharArrayPool slowPool(&slowAllocator);
229/// FastCharArrayPool fastPool(&fastAllocator);
230///
231/// bsl::shared_ptr<CharArray> charArray_sp;
232///
233/// fastPool.getCharArray(&charArray_sp);
234/// slowPool.getCharArray(&charArray_sp); // throw away the first array
235/// }
236///
237/// assert(2 == slowAllocator.numAllocations());
238/// assert(1 == fastAllocator.numAllocations());
239/// assert(0 == slowAllocator.numBytesInUse());
240/// assert(0 == fastAllocator.numBytesInUse());
241/// @endcode
242/// @}
243/** @} */
244/** @} */
245
246/** @addtogroup bdl
247 * @{
248 */
249/** @addtogroup bdlcc
250 * @{
251 */
252/** @addtogroup bdlcc_sharedobjectpool
253 * @{
254 */
255
256#include <bdlscm_version.h>
257
258#include <bdlcc_objectpool.h>
259
260#include <bdlf_bind.h>
261#include <bdlf_placeholder.h>
262
265
266#include <bslma_allocator.h>
267#include <bslma_sharedptrrep.h>
269
271
272#include <bsls_keyword.h>
273#include <bsls_objectbuffer.h>
274#include <bsls_platform.h>
275
276#include <bsl_memory.h>
277
278
279namespace bdlcc {
280
281 // ==========================
282 // class SharedObjectPool_Rep
283 // ==========================
284
285template <class TYPE, class RESETTER>
287
289 typedef ObjectPool<MyType,
292 PoolType;
293
294 // DATA
295 bslalg::ConstructorProxy<RESETTER> d_objectResetter;
296
297 PoolType *d_pool_p; // object pool (held)
298 bsls::ObjectBuffer<TYPE> d_instance; // area for embedded
299 // instance
300
301 // NOT IMPLEMENTED
304
305 public:
306 // CREATORS
307
308 /// Construct a new rep object that, upon release, will invoke the
309 /// specified `objectResetter` and return itself to the specified
310 /// `pool`; then invoke `objectCreator` to construct an object of `TYPE`
311 /// embedded within the new rep object. Use the specified
312 /// `basicAllocator` to supply memory. If `basicAllocator` is 0, the
313 /// currently installed default allocator is used.
314 template <class CREATOR>
316 CREATOR* objectCreator,
317 const bslalg::ConstructorProxy<RESETTER>& objectResetter,
318 PoolType *pool,
319 bslma::Allocator *basicAllocator);
320
321 /// Destroy this representation object and the embedded instance of
322 /// `TYPE`.
324
325 // MANIPULATORS
326
327 /// Release this representation object. This method is invoked when the
328 /// number of weak references and the number of strong references reach
329 /// zero. This virtual override will return the object, and this
330 /// representation, to the associated pool.
332
333 /// Release the object being managed by this representation. This
334 /// method is invoked when the number of strong references reaches zero.
335 /// Note that if there are any weak references to the shared object then
336 /// this function does nothing, including not destroying the object or
337 /// returning it to the pool.
339
340 /// Invoke the object resetter specified at construction on the
341 /// associated object.
342 void reset();
343
344 /// Return NULL. Shared object pools strictly control the delete policy
345 /// for their objects, and do not expose it to end users.
346 void *getDeleter(const std::type_info& type) BSLS_KEYWORD_OVERRIDE;
347
348 // ACCESSORS
349
350 /// Return (untyped) address of the object managed by this
351 /// representation. This virtual override effectively returns
352 /// "(void*)ptr()".
354
355 /// Return a pointer to the in-place object.
356 TYPE *ptr();
357};
358
359 // ======================
360 // class SharedObjectPool
361 // ======================
362
363template <class TYPE,
365 class RESETTER=ObjectPoolFunctors::Nil<TYPE> >
367
370 typedef ObjectPool<RepType,
373 PoolType;
374
375 typename ObjectPool_ProxyPicker<CREATOR>::template Selector<TYPE>::Proxy
376 d_objectCreator; // functor for object creation
377
379 d_objectResetter; // functor to reset object
380
381 PoolType d_pool; // object pool (owned)
382
383 private:
384 // NOT IMPLEMENTED
386 SharedObjectPool& operator=(const SharedObjectPool&);
387
388 /// Initializes a newly constructed SharedObjectPool_Rep object
389 void constructRepObject(void *memory, bslma::Allocator *alloc);
390
391 public:
392 // TYPES
393 typedef CREATOR CreatorType;
394 typedef RESETTER ResetterType;
395
396 // TRAITS
399
400 // CREATORS
401
402 explicit
403 SharedObjectPool(int growBy = -1, bslma::Allocator *basicAllocator = 0);
404
405 explicit
406 SharedObjectPool(const CREATOR& objectCreator,
407 bslma::Allocator *basicAllocator = 0);
408
409 SharedObjectPool(const CREATOR& objectCreator,
410 int growBy,
411 bslma::Allocator *basicAllocator = 0);
412 /// Create an object pool that dispenses shared pointers to TYPE. When
413 /// the pool is depleted, it increases its capacity according to the
414 /// optionally specified `growBy` value. If `growBy` is positive, the
415 /// pool always increases by at least `growBy`. If `growBy` is
416 /// negative, the amount of increase begins at `-growBy` and then grows
417 /// geometrically up to an implementation-defined maximum. The
418 /// optionally specified `objectCreator` is called whenever objects must
419 /// be constructed. If `objectCreator` is not specified and the
420 /// parameterized `CREATOR` is the default type (that is,
421 /// `ObjectPoolFunctors::DefaultCreator`), a function that calls the
422 /// default constructor of `TYPE` with placement new, passing this
423 /// pool`s allocator if TYPE uses allocator, is used. If the
424 /// parameterized `CREATOR` is some other type, and `objectCreator` is
425 /// not specified, the default value of the `CREATOR` type is used. The
426 /// optionally specified `objectResetter` is invoked with a pointer to
427 /// an object of `TYPE` when the object is returned to the pool. It
428 /// must reset the object into a valid state for reuse. If
429 /// `objectResetter` is not specified, a default RESETTER object is
430 /// used. Optionally specify a basic allocator to supply memory. If
431 /// `basicAllocator` is 0, the currently installed default allocator is
432 /// used. The behavior is undefined if `growBy` is 0.
433
434 SharedObjectPool(const CREATOR& objectCreator,
435 const RESETTER& objectResetter,
436 int growBy = -1,
437 bslma::Allocator *basicAllocator = 0);
438
439
440 /// Destroy this object pool. All objects created by this pool are
441 /// destroyed (even if some of them are still in use) and memory is
442 /// reclaimed.
444
445 // MANIPULATORS
446
447 /// Return a pointer to an object from this object pool. When the last
448 /// shared pointer to the object is destroyed, the object will be reset as
449 /// specified at construction and then returned to the pool. If this pool
450 /// is empty, it is replenished according to the strategy specified at
451 /// construction.
453
454 /// Create the specified `growBy` objects and add them to this object pool.
455 /// The behavior is undefined unless `0 <= growBy`.
456 void increaseCapacity(int growBy);
457
458 /// Create enough objects to satisfy requests for at least the specified
459 /// `growBy` objects before the next replenishment. The behavior is
460 /// undefined unless `0 <= growBy`. Note that this method is different
461 /// from `increaseCapacity` in that the number of created objects may be
462 /// less than `growBy`.
463 void reserveCapacity(int growBy);
464
465 // ACCESSORS
466
467 /// Return a *snapshot* of the number of objects available in this pool.
469
470 /// Return the (instantaneous) number of objects managed by this pool.
471 /// This includes both the objects available in the pool and the objects
472 /// that were allocated from the pool and not yet released.
473 int numObjects() const;
474};
475
476// ============================================================================
477// INLINE DEFINITIONS
478// ============================================================================
479
480 // --------------------------
481 // class SharedObjectPool_Rep
482 // --------------------------
483
484// CREATORS
485template <class TYPE, class RESETTER>
486template <class CREATOR>
487inline
489 CREATOR* objectCreator,
490 const bslalg::ConstructorProxy<RESETTER>& objectResetter,
491 PoolType *pool,
492 bslma::Allocator *basicAllocator)
493: d_objectResetter(objectResetter,basicAllocator)
494, d_pool_p(pool)
495{
496 (*objectCreator)(d_instance.buffer(), basicAllocator);
497}
498
499template <class TYPE, class RESETTER>
500inline
502{
503 d_instance.object().~TYPE();
504}
505
506// MANIPULATORS
507template <class TYPE, class RESETTER>
508inline
510{
511 d_objectResetter.object()(&d_instance.object());
512}
513
514template <class TYPE, class RESETTER>
515inline
517{
518 d_pool_p->releaseObject(this);
519}
520
521template <class TYPE, class RESETTER>
522inline
524 const std::type_info& /*type*/)
525{
526 return 0;
527}
528
529template <class TYPE, class RESETTER>
530inline
535
536// ACCESSORS
537template <class TYPE, class RESETTER>
538inline
540{
541 return const_cast<void*>(static_cast<const void*>(d_instance.buffer()));
542}
543
544template <class TYPE, class RESETTER>
545inline
547{
548 return &d_instance.object();
549}
550
551 // ----------------
552 // SharedObjectPool
553 // ----------------
554
555// PRIVATE
556template <class TYPE, class CREATOR, class RESETTER>
557inline
559 void *memory,
560 bslma::Allocator *alloc)
561{
562 RepType *r = new (memory) RepType(&d_objectCreator.object(),
563 d_objectResetter,
564 &d_pool,
565 alloc);
566 r->resetCountsRaw(0, 0);
567}
568
569} // close package namespace
570
571// CREATORS
572#if defined(BSLS_PLATFORM_CMP_MSVC)
573// Visual C++ complains about any use of the 'this' pointer in a member
574// initializer of a constructor. The use cases below seem perfectly safe and
575// correct, but there is no way to eliminate this warning from a prominent
576// header file other than disabling it via a pragma.
577#pragma warning(push)
578#pragma warning(disable : 4355) // used 'this' in member initializer
579#endif
580
581namespace bdlcc {
582
583template <class TYPE, class CREATOR, class RESETTER>
584inline
586 const CREATOR& objectCreator,
587 const RESETTER& objectResetter,
588 int growBy,
589 bslma::Allocator *basicAllocator)
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)
596{
597}
598
599template <class TYPE, class CREATOR, class RESETTER>
600inline
602 int growBy,
603 bslma::Allocator *basicAllocator)
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)
610{
611}
612
613template <class TYPE, class CREATOR, class RESETTER>
614inline
616 const CREATOR& objectCreator,
617 int growBy,
618 bslma::Allocator *basicAllocator)
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)
625{
626}
627
628template <class TYPE, class CREATOR, class RESETTER>
629inline
631 const CREATOR& objectCreator,
632 bslma::Allocator *basicAllocator)
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),
638 -1, basicAllocator)
639{
640}
641} // close package namespace
642
643#if defined(BSLS_PLATFORM_CMP_MSVC)
644// Restore warnings so as not to affect their state in other files.
645#pragma warning(pop)
646#endif
647
648namespace bdlcc {
649
650template <class TYPE, class CREATOR, class RESETTER>
651inline
655
656// MANIPULATORS
657template <class TYPE, class CREATOR, class RESETTER>
658inline
661{
662 RepType *rep = d_pool.getObject();
663 bslma::SharedPtrRep *genericRep = rep;
664 genericRep->resetCountsRaw(1, 0);
665
666 return bsl::shared_ptr<TYPE>(rep->ptr(), genericRep);
667}
668
669template <class TYPE, class CREATOR, class RESETTER>
670inline
671void
673{
674 d_pool.increaseCapacity(growBy);
675}
676
677template <class TYPE, class CREATOR, class RESETTER>
678inline
679void
681{
682 d_pool.reserveCapacity(growBy);
683}
684
685// ACCESSORS
686template <class TYPE, class CREATOR, class RESETTER>
687inline
689{
690 return d_pool.numAvailableObjects();
691}
692
693template <class TYPE, class CREATOR, class RESETTER>
694inline
696{
697 return d_pool.numObjects();
698}
699} // close package namespace
700
701
702
703#endif
704
705// ----------------------------------------------------------------------------
706// Copyright 2015 Bloomberg Finance L.P.
707//
708// Licensed under the Apache License, Version 2.0 (the "License");
709// you may not use this file except in compliance with the License.
710// You may obtain a copy of the License at
711//
712// http://www.apache.org/licenses/LICENSE-2.0
713//
714// Unless required by applicable law or agreed to in writing, software
715// distributed under the License is distributed on an "AS IS" BASIS,
716// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
717// See the License for the specific language governing permissions and
718// limitations under the License.
719// ----------------------------- END-OF-FILE ----------------------------------
720
721/** @} */
722/** @} */
723/** @} */
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