BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlcc.h
Go to the documentation of this file.
1/// @file bdlcc.h
2///
3///
4/// @defgroup bdlcc Package bdlcc
5/// @brief Basic Development Library Concurrency Containers (bdlcc)
6/// @addtogroup bdl
7/// @{
8/// @addtogroup bdlcc
9/// [bdlcc]: group__bdlcc.html
10/// @{
11///
12/// # Purpose {#bdlcc-purpose}
13/// Provide containers that support concurrent (multi-thread) access.
14///
15/// # Mnemonic {#bdlcc-mnemonic}
16/// Basic Development Library Concurrency Containers (bdlcc)
17///
18/// @see bdlc, bdlmt
19///
20/// # Description {#bdlcc-description}
21/// The 'bdlcc' package provides a set of containers that allow
22/// concurrent access and manipulation. Components in this package are similar in
23/// *intent* to the corresponding 'bdlc' components, except that all operations
24/// which change the internal state of the containers are guaranteed to be atomic
25/// in the presence of multiple threads.
26///
27/// Support for true multi-threading causes some significant interface changes
28/// when compared to the analogous 'bdlc' components. A thread-safe collection
29/// cannot, in general, guarantee thread safety for its contained objects while
30/// still allowing access to those objects. So, for instance, a canonical
31/// implementation of 'operator[]', yielding a reference to the contained object,
32/// would violate thread safety. Therefore, thread-safe collections will, in
33/// general, return items *by* *value* rather than *by* *reference*.
34///
35/// In addition, thread-aware collection components must make policy decisions
36/// regarding behavior of manipulators at the "edge conditions" when a collection
37/// is empty or full. In a multi-threading context, it is often reasonable for a
38/// manipulator to block if it cannot complete a requested operation, and to wait
39/// for the collection state to change. For instance, when called for an empty
40/// collection, 'bdlcc_Queue<T>::popFront()' will block and then wait until an
41/// element is available to satisfy the request.
42///
43/// In general, components in 'bdlcc' support this blocking behavior where it
44/// makes sense. Refer to the individual component documentation to understand
45/// how this general principle is carried out in specific components.
46///
47/// Unless otherwise stated, the behavior of the destructors of components in the
48/// 'bdlcc' package is undefined unless all access or modification of the object
49/// is completed prior to its destruction. Some form of synchronization, external
50/// to the component, is required to ensure this precondition on the destructor is
51/// met. For example, if two (or more) threads are manipulating a container, it
52/// is *not* safe to anticipate the number of elements added to the container, and
53/// destroy that container immediately after the last element is removed (without
54/// additional synchronization) because one of the corresponding insert functions
55/// may not have completed (the insert may, for instance, signal waiting threads
56/// after the element is considered added to the container).
57///
58/// ## Hierarchical Synopsis
59///
60/// The 'bdlcc' package currently has 20 components having 4 levels of physical
61/// dependency. The list below shows the hierarchical ordering of the components.
62/// The order of components within each level is not architecturally significant,
63/// just alphabetical.
64/// @code
65/// 4. bdlcc_sharedobjectpool
66///
67/// 3. bdlcc_objectpool
68///
69/// 2. bdlcc_fixedqueue
70/// bdlcc_singleconsumerqueue
71/// bdlcc_singleproducerqueue
72/// bdlcc_stripedunorderedmap
73/// bdlcc_stripedunorderedmultimap
74///
75/// 1. bdlcc_boundedqueue
76/// bdlcc_cache
77/// bdlcc_deque
78/// bdlcc_fixedqueueindexmanager
79/// bdlcc_multipriorityqueue
80/// bdlcc_objectcatalog
81/// bdlcc_queue !DEPRECATED!
82/// bdlcc_singleconsumerqueueimpl
83/// bdlcc_singleproducerqueueimpl
84/// bdlcc_singleproducersingleconsumerboundedqueue
85/// bdlcc_skiplist
86/// bdlcc_stripedunorderedcontainerimpl
87/// bdlcc_timequeue
88/// @endcode
89///
90/// ## Component Synopsis
91///
92/// @ref bdlcc_boundedqueue :
93/// Provide a thread-aware bounded queue of values.
94///
95/// @ref bdlcc_cache :
96/// Provide a in-process cache with configurable eviction policy.
97///
98/// @ref bdlcc_deque :
99/// Provide a fully thread-safe deque container.
100///
101/// @ref bdlcc_fixedqueue :
102/// Provide a thread-aware fixed-size queue of values.
103///
104/// @ref bdlcc_fixedqueueindexmanager :
105/// Provide thread-enabled state management for a fixed-size queue.
106///
107/// @ref bdlcc_multipriorityqueue :
108/// Provide a thread-enabled parameterized multi-priority queue.
109///
110/// @ref bdlcc_objectcatalog :
111/// Provide an efficient indexed, thread-safe object container.
112///
113/// @ref bdlcc_objectpool :
114/// Provide a thread-safe object pool.
115///
116/// @ref bdlcc_queue : !DEPRECATED!
117/// Provide a thread-enabled queue of items of parameterized `TYPE`.
118///
119/// @ref bdlcc_sharedobjectpool :
120/// Provide a thread-safe pool of shared objects.
121///
122/// @ref bdlcc_singleconsumerqueue :
123/// Provide a thread-aware single consumer queue of values.
124///
125/// @ref bdlcc_singleconsumerqueueimpl :
126/// Provide a testable thread-aware single consumer queue of values.
127///
128/// @ref bdlcc_singleproducerqueue :
129/// Provide a thread-aware single producer queue of values.
130///
131/// @ref bdlcc_singleproducerqueueimpl :
132/// Provide a testable thread-aware single producer queue of values.
133///
134/// @ref bdlcc_singleproducersingleconsumerboundedqueue :
135/// Provide a thread-aware SPSC bounded queue of values.
136///
137/// @ref bdlcc_skiplist :
138/// Provide a generic thread-safe Skip List.
139///
140/// @ref bdlcc_stripedunorderedcontainerimpl :
141/// Provide common implementation of *striped* un-ordered map/multimap.
142///
143/// @ref bdlcc_stripedunorderedmap :
144/// Provide a bucket-group locking (i.e., *striped*) unordered map.
145///
146/// @ref bdlcc_stripedunorderedmultimap :
147/// Provide a bucket-group locking (*striped*) unordered multimap.
148///
149/// @ref bdlcc_timequeue :
150/// Provide an efficient queue for time events.
151///
152/// ## Component Overview
153///
154/// This section provides a brief introduction to some of the components of the
155/// 'bdlcc' package. Full details are available in the documentation of each
156/// component.
157///
158/// ### @ref bdlcc_objectcatalog
159///
160/// The {@ref bdlcc_objectcatalog } component provides a thread-safe, indexable
161/// catalog of object. Clients instantiate a template class,
162/// 'bdlcc_ObjectCatalog<T>', where type 'T' is the data type of elements that the
163/// catalog will hold. Type 'T' must be defined to be copyable either by a copy
164/// constructor or by 'T::operator=()'; class 'bdlcc_ObjectCatalog' places no
165/// additional requirements on 'T'.
166///
167/// When clients add elements to a 'bdlcc_ObjectCatalog', the 'add' method returns
168/// a handle which can be used to refer to the element until the element is
169/// 'remove'd. Addition is not guaranteed to succeed and the return vaslue must
170/// be checked. An element can be accessed through its handle by using the 'find'
171/// function and passing a buffer for holding the value. Passing a null buffer
172/// can be used for testing whether the handle is still valid (i.e., refers to an
173/// element that has not yet been removed from the catalog).
174///
175/// The 'bdlcc_ObjectCatalog' is designed to support direct access to individual
176/// queued elements based upon their 'Handle'. This means that 'bdlcc_Catalog'
177/// can support frequent additions and removals more efficiently than traditional
178/// queue structures designed for sequential access.
179///
180/// ### @ref bdlcc_pool
181///
182/// The {@ref bdlcc_pool } component provides a thread-safe memory pool of objects
183/// from a parameterized type 'T'. Clients instantiate a 'bdlcc_ObjectPool<T>'
184/// where the type 'T' has no requirements. The pool owns the memory and objects
185/// it contains. An object pool manages creation of its objects via a
186/// user-installed functor (given to the pool constructor), and provides automatic
187/// destruction of its objects either upon the 'destroyObject' method, or upon the
188/// pool destruction. An object can be obtained from the pool by calling the
189/// 'getObject' method, and can be released back to the pool for further use
190/// within 'getObject' by calling the 'releaseObject' method.
191///
192/// An object pool is most useful when the objects are equivalent (i.e., any
193/// object in the pool can be used to satisfy an object request) and object
194/// creation is potentially expensive. Pooling enables the object to be reused at
195/// a later time without going through destruction and re-creation. For instance,
196/// the object constructor may get access to some resource (e.g., a connection)
197/// and the resource may remain valid after several uses and thus can be reused.
198///
199/// ### @ref bdlcc_queue
200///
201/// The {@ref bdlcc_queue } component provides an in-place, indexable, double-ended
202/// queue. Clients instantiate a template class, 'bdlcc_Queue<T>', where type 'T'
203/// is the data type of elements that the queue will hold. Type 'T' must be
204/// defined to be copyable either by a copy constructor or by 'T::operator=()';
205/// class 'bdlcc_Queue' Places no additional requirements on 'T'.
206///
207/// ### @ref bdlcc_timequeue
208///
209/// The {@ref bdlcc_timequeue } component provides an in-place, indexable queue,
210/// managed in time order. Clients instantiate a template class,
211/// 'bdlcc_TimeQueue<T>', where type 'T' is the data type of elements that the
212/// queue will hold. Type 'T' must be defined to be copyable either by a copy
213/// constructor or by 'T::operator=()'; class 'bdlcc_TimeQueue' places no
214/// additional requirements on 'T'.
215///
216/// When clients add elements to a 'bdlcc_TimeQueue', they provide both the
217/// element 'T' to be added and a time value, of type 'bsls::TimeInterval'.
218/// Elements can be extracted individually in time order using the overloaded
219/// 'popFront()' member functions; a block of elements can also be popped in a
220/// single operation, 'popLE()', which pops all elements before a given time
221/// value.
222///
223/// The 'bdlcc_TimeQueue' class template supports direct access to individual
224/// queued elements based upon their 'Handle'. This means that 'bdlcc_TimeQueue'
225/// can support frequent additions and removals more efficiently than traditional
226/// queue structures designed for sequential access.
227///
228/// @}
229/** @} */