[#BloombergLP-bdlcc-SingleProducerQueueImpl] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlcc.adoc[bdlcc]::SingleProducerQueueImpl :relfileprefix: ../../ :mrdocs: This class provides a thread‐safe unbounded queue of values that assumes a single producer thread. == Synopsis Declared in `<bdlcc_singleproducerqueueimpl.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class TYPE, class ATOMIC_OP, class MUTEX, class CONDITION> class SingleProducerQueueImpl; ---- == Description The types `ATOMIC_OP`, `MUTEX`, and `CONDITION` are exposed for testing. Typical usage is with `bsls::AtomicOperations` for `ATOMIC_OP`, `bslmt::Mutex` for `MUTEX`, and `bslmt::Condition` for `CONDITION`. == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/value_type.adoc[`value_type`] | The type for elements stored in this queue. |=== == Enums [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/_04enum.adoc[`Unnamed enum`] | Status codes returned by queue operations. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/2constructor-0c.adoc[`SingleProducerQueueImpl`] [.small]#[constructor]# | Constructors | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/2destructor.adoc[`~SingleProducerQueueImpl`] [.small]#[destructor]# | Destroy this object. | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/allocator.adoc[`allocator`] | Return the allocator used by this object to supply memory. | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/disablePopFront.adoc[`disablePopFront`] | Disable dequeueing from this queue. All subsequent invocations of `popFront` or `tryPopFront` will fail immediately. All blocked invocations of `popFront` and `waitUntilEmpty` will fail immediately. If the queue is already dequeue disabled, this method has no effect. | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/disablePushBack.adoc[`disablePushBack`] | Disable enqueueing into this queue. All subsequent invocations of `pushBack` or `tryPushBack` will fail immediately. All blocked invocations of `pushBack` will fail immediately. If the queue is already enqueue disabled, this method has no effect. | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/enablePopFront.adoc[`enablePopFront`] | Enable dequeueing. If the queue is not dequeue disabled, this call has no effect. | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/enablePushBack.adoc[`enablePushBack`] | Enable queuing. If the queue is not enqueue disabled, this call has no effect. | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/isEmpty.adoc[`isEmpty`] | Return `true` if this queue is empty (has no elements), or `false` otherwise. | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/isFull.adoc[`isFull`] | Return `true` if this queue is full (has no available capacity), or `false` otherwise. Note that for unbounded queues, this method always returns `false`. | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/isPopFrontDisabled.adoc[`isPopFrontDisabled`] | Return `true` if this queue is dequeue disabled, and `false` otherwise. Note that the queue is created in the "dequeue enabled" state. | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/isPushBackDisabled.adoc[`isPushBackDisabled`] | Return `true` if this queue is enqueue disabled, and `false` otherwise. Note that the queue is created in the "enqueue enabled" state. | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/numElements.adoc[`numElements`] | Returns the number of elements currently in this queue. | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/popFront.adoc[`popFront`] | Remove the element from the front of this queue and load that element into the specified `value`. If the queue is empty, block until it is not empty. Return 0 on success, and a non‐zero value otherwise. Specifically, return `e_DISABLED` if `isPopFrontDisabled()`. On failure, `value` is not changed. Threads blocked due to the queue being empty will return `e_DISABLED` if `disablePopFront` is invoked. | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/pushBack-04.adoc[`pushBack`] | `pushBack` overloads | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/removeAll.adoc[`removeAll`] | Remove all items currently in this queue. Note that this operation is not atomic; if other threads are concurrently pushing items into the queue the result of `numElements()` after this function returns is not guaranteed to be 0. | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/tryPopFront.adoc[`tryPopFront`] | Attempt to remove the element from the front of this queue without blocking, and, if successful, load the specified `value` with the removed element. Return 0 on success, and a non‐zero value otherwise. Specifically, return `e_DISABLED` if `isPopFrontDisabled()`, and `e_EMPTY` if `!isPopFrontDisabled()` and the queue was empty. On failure, `value` is not changed. | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/tryPushBack-08.adoc[`tryPushBack`] | `tryPushBack` overloads | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/waitUntilEmpty.adoc[`waitUntilEmpty`] | Block until all the elements in this queue are removed. Return 0 on success, and a non‐zero value otherwise. Specifically, return `e_DISABLED` if `!isEmpty() && isPopFrontDisabled()`. A blocked thread waiting for the queue to empty will return `e_DISABLED` if `disablePopFront` is invoked. | xref:BloombergLP/bdlcc/SingleProducerQueueImpl/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<SingleProducerQueueImpl, UsesBslmaAllocator>`] | Declare that this type uses a `bslma` allocator. |=== == Friends [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bdlcc/SingleProducerQueueImpl_PopCompleteGuard.adoc[BloombergLP::bdlcc::SingleProducerQueueImpl_PopCompleteGuard]` | This class implements a guard automatically invokes `popComplete` on a `NODE` upon destruction. | `xref:BloombergLP/bdlcc/SingleProducerQueueImpl_ReleaseAllRawProctor.adoc[BloombergLP::bdlcc::SingleProducerQueueImpl_ReleaseAllRawProctor]` | This class implements a proctor that, unless its `release` method has previously been invoked, automatically invokes `releaseAllRaw` on a `TYPE` upon destruction. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#