[#BloombergLP-bdlcc-SingleConsumerQueueImpl]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlcc.adoc[bdlcc]::SingleConsumerQueueImpl
:relfileprefix: ../../
:mrdocs:

This class provides a thread&hyphen;safe unbounded queue of values that assumes a single consumer thread&period;

== Synopsis

Declared in `&lt;bdlcc&lowbar;singleconsumerqueueimpl&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class TYPE,
    class ATOMIC&lowbar;OP,
    class MUTEX,
    class CONDITION&gt;
class SingleConsumerQueueImpl;
----

== Description

The types `ATOMIC&lowbar;OP`, `MUTEX`, and `CONDITION` are exposed for testing&period; Typical usage is with `bsls&colon;&colon;AtomicOperations` for `ATOMIC&lowbar;OP`, `bslmt&colon;&colon;Mutex` for `MUTEX`, and `bslmt&colon;&colon;Condition` for `CONDITION`&period;

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/value_type.adoc[`value&lowbar;type`] 
| The type for elements stored in this queue&period;
|===


== Enums

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/_04enum.adoc[`Unnamed enum`] 
| Status codes returned by queue operations&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/2constructor-02.adoc[`SingleConsumerQueueImpl`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/2destructor.adoc[`&#126;SingleConsumerQueueImpl`] [.small]#[destructor]#
| Destroy this container&period; The behavior is undefined unless all access or modification of the container has completed prior to this call&period;
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/allocator.adoc[`allocator`] 
| Return the allocator used by this object to supply memory&period;
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/disablePopFront.adoc[`disablePopFront`] 
| Disable dequeueing from this queue&period; All subsequent invocations of `popFront` or `tryPopFront` will fail immediately&period; All blocked invocations of `popFront` and `waitUntilEmpty` will fail immediately&period; If the queue is already dequeue disabled, this method has no effect&period;
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/disablePushBack.adoc[`disablePushBack`] 
| Disable enqueueing into this queue&period; All subsequent invocations of `pushBack` or `tryPushBack` will fail immediately&period; All blocked invocations of `pushBack` will fail immediately&period; If the queue is already enqueue disabled, this method has no effect&period;
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/enablePopFront.adoc[`enablePopFront`] 
| Enable dequeueing&period; If the queue is not dequeue disabled, this call has no effect&period;
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/enablePushBack.adoc[`enablePushBack`] 
| Enable queuing&period; If the queue is not enqueue disabled, this call has no effect&period;
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/isEmpty.adoc[`isEmpty`] 
| Return `true` if this queue is empty (has no elements), or `false` otherwise&period;
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/isFull.adoc[`isFull`] 
| Return `true` if this queue is full (has no available capacity), or `false` otherwise&period; Note that for unbounded queues, this method always returns `false`&period;
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/isPopFrontDisabled.adoc[`isPopFrontDisabled`] 
| Return `true` if this queue is dequeue disabled, and `false` otherwise&period; Note that the queue is created in the &quot;dequeue enabled&quot; state&period;
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/isPushBackDisabled.adoc[`isPushBackDisabled`] 
| Return `true` if this queue is enqueue disabled, and `false` otherwise&period; Note that the queue is created in the &quot;enqueue enabled&quot; state&period;
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/numElements.adoc[`numElements`] 
| Returns the number of elements currently in this queue&period;
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/popFront.adoc[`popFront`] 
| Remove the element from the front of this queue and load that element into the specified `value`&period; If the queue is empty, block until it is not empty&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; Specifically, return `e&lowbar;DISABLED` if `isPopFrontDisabled()`&period; On failure, `value` is not changed&period; Threads blocked due to the queue being empty will return `e&lowbar;DISABLED` if `disablePopFront` is invoked&period; The behavior is undefined unless the invoker of this method is the single consumer&period;
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/pushBack-02.adoc[`pushBack`] 
| `pushBack` overloads
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/removeAll.adoc[`removeAll`] 
| Remove all items currently in this queue&period; Note that this operation is not atomic&semi; if other threads are concurrently pushing items into the queue the result of `numElements()` after this function returns is not guaranteed to be 0&period; The behavior is undefined unless the invoker of this method is the single consumer&period;
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/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&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; Specifically, return `e&lowbar;DISABLED` if `isPopFrontDisabled()`, and `e&lowbar;EMPTY` if `!isPopFrontDisabled()` and the queue was empty&period; On failure, `value` is not changed&period; The behavior is undefined unless the invoker of this method is the single consumer&period;
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/tryPushBack-0d.adoc[`tryPushBack`] 
| `tryPushBack` overloads
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/waitUntilEmpty.adoc[`waitUntilEmpty`] 
| Block until all the elements in this queue are removed&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; Specifically, return `e&lowbar;DISABLED` if `!isEmpty() &amp;&amp; isPopFrontDisabled()`&period; A blocked thread waiting for the queue to empty will return `e&lowbar;DISABLED` if `disablePopFront` is invoked&period;
| xref:BloombergLP/bdlcc/SingleConsumerQueueImpl/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;SingleConsumerQueueImpl, UsesBslmaAllocator&gt;`] 
| Declare that this type uses a `bslma` allocator&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/bdlcc/SingleConsumerQueueImpl_AllocateLockGuard.adoc[BloombergLP::bdlcc::SingleConsumerQueueImpl&lowbar;AllocateLockGuard]`
| This class implements a guard that automatically invokes `releaseAllocateLock` on the managed queue upon destruction&period;
| `xref:BloombergLP/bdlcc/SingleConsumerQueueImpl_PopCompleteGuard.adoc[BloombergLP::bdlcc::SingleConsumerQueueImpl&lowbar;PopCompleteGuard]`
| This class implements a guard that automatically invokes `popComplete` on the managed queue upon destruction&period;
| `xref:BloombergLP/bdlcc/SingleConsumerQueueImpl_MarkReclaimProctor.adoc[BloombergLP::bdlcc::SingleConsumerQueueImpl&lowbar;MarkReclaimProctor]`
| This class implements a proctor that, unless its `release` method has previously been invoked, automatically invokes `markReclaim` on a `NODE` upon destruction&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
