BDE 4.39.x 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_pointerutil.h>
268#include <bslma_sharedptrrep.h>
270
272
273#include <bsls_keyword.h>
274#include <bsls_objectbuffer.h>
275#include <bsls_platform.h>
276
277#include <bsl_memory.h>
278
279
280namespace bdlcc {
281
282 // ==========================
283 // class SharedObjectPool_Rep
284 // ==========================
285
286template <class TYPE, class RESETTER>
288
290 typedef ObjectPool<MyType,
293 PoolType;
294
295 // DATA
296 bslalg::ConstructorProxy<RESETTER> d_objectResetter;
297
298 PoolType *d_pool_p; // object pool (held)
299 bsls::ObjectBuffer<TYPE> d_instance; // area for embedded
300 // instance
301
302 private:
303 // NOT IMPLEMENTED
306
307 public:
308 // CREATORS
309
310 /// Construct a new rep object that, upon release, will invoke the
311 /// specified `objectResetter` and return itself to the specified
312 /// `pool`; then invoke `objectCreator` to construct an object of `TYPE`
313 /// embedded within the new rep object. Use the specified
314 /// `basicAllocator` to supply memory. If `basicAllocator` is 0, the
315 /// currently installed default allocator is used.
316 template <class CREATOR>
318 CREATOR* objectCreator,
319 const bslalg::ConstructorProxy<RESETTER>& objectResetter,
320 PoolType *pool,
321 bslma::Allocator *basicAllocator);
322
323 /// Destroy this representation object and the embedded instance of
324 /// `TYPE`.
326
327 // MANIPULATORS
328
329 /// Release this representation object. This method is invoked when the
330 /// number of weak references and the number of strong references reach
331 /// zero. This virtual override will return the object, and this
332 /// representation, to the associated pool.
334
335 /// Release the object being managed by this representation. This
336 /// method is invoked when the number of strong references reaches zero.
337 ///
338 /// \note Note that if there are any weak references to the shared object then
339 /// this function does nothing, including not destroying the object or
340 /// returning it to the pool.
342
343 /// Invoke the object resetter specified at construction on the
344 /// associated object.
345 void reset();
346
347 /// Return NULL. Shared object pools strictly control the delete policy
348 /// for their objects, and do not expose it to end users.
349 void *getDeleter(const std::type_info& type) BSLS_KEYWORD_OVERRIDE;
350
351 // ACCESSORS
352
353 /// Return (untyped) address of the object managed by this
354 /// representation. This virtual override effectively returns
355 /// "(void*)ptr()".
357
358 /// Return a pointer to the in-place object.
359 TYPE *ptr();
360};
361
362 // ======================
363 // class SharedObjectPool
364 // ======================
365
366template <class TYPE,
368 class RESETTER=ObjectPoolFunctors::Nil<TYPE> >
370
373 typedef ObjectPool<RepType,
376 PoolType;
377
378 typename ObjectPool_ProxyPicker<CREATOR>::template Selector<TYPE>::Proxy
379 d_objectCreator; // functor for object creation
380
382 d_objectResetter; // functor to reset object
383
384 PoolType d_pool; // object pool (owned)
385
386 private:
387 // NOT IMPLEMENTED
389 SharedObjectPool& operator=(const SharedObjectPool&);
390
391 /// Initializes a newly constructed SharedObjectPool_Rep object
392 void constructRepObject(void *memory, bslma::Allocator *alloc);
393
394 public:
395 // TYPES
396 typedef CREATOR CreatorType;
397 typedef RESETTER ResetterType;
398
399 // TRAITS
402
403 // CREATORS
404
405 /// Create an object pool that dispenses shared pointers to TYPE. When
406 /// the pool is depleted, it increases its capacity according to the
407 /// optionally specified `growBy` value. If `growBy` is positive, the
408 /// pool always increases by at least `growBy`. If `growBy` is
409 /// negative, the amount of increase begins at `-growBy` and then grows
410 /// geometrically up to an implementation-defined maximum. The
411 /// optionally specified `objectCreator` is called whenever objects must
412 /// be constructed. If `objectCreator` is not specified and the
413 /// parameterized `CREATOR` is the default type (that is,
414 /// `ObjectPoolFunctors::DefaultCreator`), a function that calls the
415 /// default constructor of `TYPE` with placement new, passing this
416 /// pool's allocator if TYPE uses allocator, is used. If the
417 /// parameterized `CREATOR` is some other type, and `objectCreator` is
418 /// not specified, the default value of the `CREATOR` type is used. The
419 /// optionally specified `objectResetter` is invoked with a pointer to
420 /// an object of `TYPE` when the object is returned to the pool. It
421 /// must reset the object into a valid state for reuse. If
422 /// `objectResetter` is not specified, a default `RESETTER` object is
423 /// used. Optionally specify a basic allocator to supply memory. If
424 /// `basicAllocator` is 0, the currently installed default allocator is used.
425 ///
426 /// \pre The behavior is undefined if `growBy` is 0.
427 explicit
428 SharedObjectPool(int growBy = -1, bslma::Allocator *basicAllocator = 0);
429
430 explicit
431 SharedObjectPool(const CREATOR& objectCreator,
432 bslma::Allocator *basicAllocator = 0);
433
434 SharedObjectPool(const CREATOR& objectCreator,
435 int growBy,
436 bslma::Allocator *basicAllocator = 0);
437
438 SharedObjectPool(const CREATOR& objectCreator,
439 const RESETTER& objectResetter,
440 int growBy = -1,
441 bslma::Allocator *basicAllocator = 0);
442
443
444 /// Destroy this object pool. All objects created by this pool are
445 /// destroyed (even if some of them are still in use) and memory is
446 /// reclaimed.
448
449 // MANIPULATORS
450
451 /// Return a pointer to an object from this object pool. When the last
452 /// shared pointer to the object is destroyed, the object will be reset as
453 /// specified at construction and then returned to the pool. If this pool
454 /// is empty, it is replenished according to the strategy specified at
455 /// construction.
457
458 /// Create the specified `growBy` objects and add them to this object pool.
459 ///
460 /// \pre The behavior is undefined unless `0 <= growBy`.
461 void increaseCapacity(int growBy);
462
463 /// Create enough objects to satisfy requests for at least the specified
464 /// `growBy` objects before the next replenishment.
465 ///
466 /// \pre The behavior is undefined unless `0 <= growBy`.
467 /// \note Note that this method is different
468 /// from `increaseCapacity` in that the number of created objects may be
469 /// less than `growBy`.
470 void reserveCapacity(int growBy);
471
472 // ACCESSORS
473
474 /// Return a *snapshot* of the number of objects available in this pool.
476
477 /// Return the (instantaneous) number of objects managed by this pool.
478 /// This includes both the objects available in the pool and the objects
479 /// that were allocated from the pool and not yet released.
480 int numObjects() const;
481};
482
483// ============================================================================
484// INLINE DEFINITIONS
485// ============================================================================
486
487 // --------------------------
488 // class SharedObjectPool_Rep
489 // --------------------------
490
491// CREATORS
492template <class TYPE, class RESETTER>
493template <class CREATOR>
494inline
496 CREATOR* objectCreator,
497 const bslalg::ConstructorProxy<RESETTER>& objectResetter,
498 PoolType *pool,
499 bslma::Allocator *basicAllocator)
500: d_objectResetter(objectResetter,basicAllocator)
501, d_pool_p(pool)
502{
503 (*objectCreator)(d_instance.buffer(), basicAllocator);
504}
505
506template <class TYPE, class RESETTER>
507inline
509{
510 d_instance.object().~TYPE();
511}
512
513// MANIPULATORS
514template <class TYPE, class RESETTER>
515inline
517{
518 d_objectResetter.object()(&d_instance.object());
519}
520
521template <class TYPE, class RESETTER>
522inline
524{
525 d_pool_p->releaseObject(this);
526}
527
528template <class TYPE, class RESETTER>
529inline
531 const std::type_info& /*type*/)
532{
533 return 0;
534}
535
536template <class TYPE, class RESETTER>
537inline
542
543// ACCESSORS
544template <class TYPE, class RESETTER>
545inline
547{
548 return bslma::PointerUtil::voidify(d_instance.buffer());
549}
550
551template <class TYPE, class RESETTER>
552inline
554{
555 return &d_instance.object();
556}
557
558 // ----------------
559 // SharedObjectPool
560 // ----------------
561
562// PRIVATE
563template <class TYPE, class CREATOR, class RESETTER>
564inline
566 void *memory,
567 bslma::Allocator *alloc)
568{
569 RepType *r = new (memory) RepType(&d_objectCreator.object(),
570 d_objectResetter,
571 &d_pool,
572 alloc);
573 r->resetCountsRaw(0, 0);
574}
575
576} // close package namespace
577
578// CREATORS
579#if defined(BSLS_PLATFORM_CMP_MSVC)
580// Visual C++ complains about any use of the 'this' pointer in a member
581// initializer of a constructor. The use cases below seem perfectly safe and
582// correct, but there is no way to eliminate this warning from a prominent
583// header file other than disabling it via a pragma.
584#pragma warning(push)
585#pragma warning(disable : 4355) // used 'this' in member initializer
586#endif
587
588namespace bdlcc {
589
590template <class TYPE, class CREATOR, class RESETTER>
591inline
593 const CREATOR& objectCreator,
594 const RESETTER& objectResetter,
595 int growBy,
596 bslma::Allocator *basicAllocator)
597: d_objectCreator(objectCreator,basicAllocator)
598, d_objectResetter(objectResetter,basicAllocator)
599, d_pool(bdlf::BindUtil::bind(&MyType::constructRepObject, this,
600 bdlf::PlaceHolders::_1,
601 bdlf::PlaceHolders::_2),
602 growBy, basicAllocator)
603{
604}
605
606template <class TYPE, class CREATOR, class RESETTER>
607inline
609 int growBy,
610 bslma::Allocator *basicAllocator)
611: d_objectCreator(basicAllocator)
612, d_objectResetter(basicAllocator)
613, d_pool(bdlf::BindUtil::bind(&MyType::constructRepObject, this,
614 bdlf::PlaceHolders::_1,
615 bdlf::PlaceHolders::_2),
616 growBy, basicAllocator)
617{
618}
619
620template <class TYPE, class CREATOR, class RESETTER>
621inline
623 const CREATOR& objectCreator,
624 int growBy,
625 bslma::Allocator *basicAllocator)
626: d_objectCreator(objectCreator, basicAllocator)
627, d_objectResetter(basicAllocator)
628, d_pool(bdlf::BindUtil::bind(&MyType::constructRepObject, this,
629 bdlf::PlaceHolders::_1,
630 bdlf::PlaceHolders::_2),
631 growBy, basicAllocator)
632{
633}
634
635template <class TYPE, class CREATOR, class RESETTER>
636inline
638 const CREATOR& objectCreator,
639 bslma::Allocator *basicAllocator)
640: d_objectCreator(objectCreator, basicAllocator)
641, d_objectResetter(basicAllocator)
642, d_pool(bdlf::BindUtil::bind(&MyType::constructRepObject, this,
643 bdlf::PlaceHolders::_1,
644 bdlf::PlaceHolders::_2),
645 -1, basicAllocator)
646{
647}
648} // close package namespace
649
650#if defined(BSLS_PLATFORM_CMP_MSVC)
651// Restore warnings so as not to affect their state in other files.
652#pragma warning(pop)
653#endif
654
655namespace bdlcc {
656
657template <class TYPE, class CREATOR, class RESETTER>
658inline
662
663// MANIPULATORS
664template <class TYPE, class CREATOR, class RESETTER>
665inline
668{
669 RepType *rep = d_pool.getObject();
670 bslma::SharedPtrRep *genericRep = rep;
671 genericRep->resetCountsRaw(1, 0);
672
673 return bsl::shared_ptr<TYPE>(rep->ptr(), genericRep);
674}
675
676template <class TYPE, class CREATOR, class RESETTER>
677inline
678void
680{
681 d_pool.increaseCapacity(growBy);
682}
683
684template <class TYPE, class CREATOR, class RESETTER>
685inline
686void
688{
689 d_pool.reserveCapacity(growBy);
690}
691
692// ACCESSORS
693template <class TYPE, class CREATOR, class RESETTER>
694inline
696{
697 return d_pool.numAvailableObjects();
698}
699
700template <class TYPE, class CREATOR, class RESETTER>
701inline
703{
704 return d_pool.numObjects();
705}
706} // close package namespace
707
708
709
710#endif
711
712// ----------------------------------------------------------------------------
713// Copyright 2015 Bloomberg Finance L.P.
714//
715// Licensed under the Apache License, Version 2.0 (the "License");
716// you may not use this file except in compliance with the License.
717// You may obtain a copy of the License at
718//
719// http://www.apache.org/licenses/LICENSE-2.0
720//
721// Unless required by applicable law or agreed to in writing, software
722// distributed under the License is distributed on an "AS IS" BASIS,
723// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
724// See the License for the specific language governing permissions and
725// limitations under the License.
726// ----------------------------- END-OF-FILE ----------------------------------
727
728/** @} */
729/** @} */
730/** @} */
Definition bdlcc_objectpool.h:430
Definition bdlcc_objectpool.h:446
Definition bdlcc_objectpool.h:694
Definition bdlcc_sharedobjectpool.h:287
void reset()
Definition bdlcc_sharedobjectpool.h:516
void * originalPtr() const BSLS_KEYWORD_OVERRIDE
Definition bdlcc_sharedobjectpool.h:546
TYPE * ptr()
Return a pointer to the in-place object.
Definition bdlcc_sharedobjectpool.h:553
void disposeObject() BSLS_KEYWORD_OVERRIDE
Definition bdlcc_sharedobjectpool.h:538
~SharedObjectPool_Rep() BSLS_KEYWORD_OVERRIDE
Definition bdlcc_sharedobjectpool.h:508
void * getDeleter(const std::type_info &type) BSLS_KEYWORD_OVERRIDE
Definition bdlcc_sharedobjectpool.h:530
void disposeRep() BSLS_KEYWORD_OVERRIDE
Definition bdlcc_sharedobjectpool.h:523
Definition bdlcc_sharedobjectpool.h:369
void reserveCapacity(int growBy)
Definition bdlcc_sharedobjectpool.h:687
CREATOR CreatorType
Definition bdlcc_sharedobjectpool.h:396
void increaseCapacity(int growBy)
Definition bdlcc_sharedobjectpool.h:679
~SharedObjectPool()
Definition bdlcc_sharedobjectpool.h:659
RESETTER ResetterType
Definition bdlcc_sharedobjectpool.h:397
SharedObjectPool(const CREATOR &objectCreator, const RESETTER &objectResetter, int growBy=-1, bslma::Allocator *basicAllocator=0)
Definition bdlcc_sharedobjectpool.h:592
BSLMF_NESTED_TRAIT_DECLARATION(SharedObjectPool, bslma::UsesBslmaAllocator)
SharedObjectPool(const CREATOR &objectCreator, bslma::Allocator *basicAllocator=0)
Definition bdlcc_sharedobjectpool.h:637
SharedObjectPool(const CREATOR &objectCreator, int growBy, bslma::Allocator *basicAllocator=0)
Definition bdlcc_sharedobjectpool.h:622
bsl::shared_ptr< TYPE > getObject()
Definition bdlcc_sharedobjectpool.h:667
SharedObjectPool(int growBy=-1, bslma::Allocator *basicAllocator=0)
Definition bdlcc_sharedobjectpool.h:608
int numObjects() const
Definition bdlcc_sharedobjectpool.h:702
int numAvailableObjects() const
Return a snapshot of the number of objects available in this pool.
Definition bdlcc_sharedobjectpool.h:695
Definition bslstl_sharedptr.h:1838
Definition bslalg_constructorproxy.h:376
Definition bslma_allocator.h:545
Definition bslma_sharedptrrep.h:338
void resetCountsRaw(int numSharedReferences, int numWeakReferences)
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
#define BSLS_KEYWORD_OVERRIDE
Definition bsls_keyword.h:695
Definition bdlcc_boundedqueue.h:270
Definition bdlf_bind.h:979
bsl::function< void(void *, bslma::Allocator *)> DefaultCreator
Definition bdlcc_objectpool.h:421
Definition bdlcc_objectpool.h:663
static BSLS_KEYWORD_CONSTEXPR void * voidify(TYPE *address) BSLS_KEYWORD_NOEXCEPT
Definition bslma_pointerutil.h:350
Definition bslma_usesbslmaallocator.h:344
Definition bsls_objectbuffer.h:277