[#BloombergLP-bdlmt-MultiQueueThreadPool_Queue]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlmt.adoc[bdlmt]::MultiQueueThreadPool&lowbar;Queue
:relfileprefix: ../../
:mrdocs:

This private class provides a thread&hyphen;safe, lightweight job queue&period;

== Synopsis

Declared in `&lt;bdlmt&lowbar;multiqueuethreadpool&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class MultiQueueThreadPool&lowbar;Queue;
----

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/Job.adoc[`Job`] 
| Defines a type alias for the job functor type&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/2constructor-0508.adoc[`MultiQueueThreadPool&lowbar;Queue`]         [.small]#[constructor]#
| Create a `MultiQueueThreadPool&lowbar;Queue` with an initial capacity of 0 and initialized to use the specified `multiQueueThreadPool` to track aggregate values (e&period;g&period;, the number of active queues) and to obtain the thread pool used to execute jobs that are appended to this queue&period; Optionally specify a `basicAllocator` used to supply memory&period; If `basicAllocator` is 0, the default memory allocator is used&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/2destructor.adoc[`&#126;MultiQueueThreadPool&lowbar;Queue`] [.small]#[destructor]#
| Destroy this queue&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/batchSize.adoc[`batchSize`] 
| Return an instantaneous snapshot of the execution batch size (see &lcub;`Job Execution Batch Size`&rcub;)&period; When a thread is selecting jobs for processing, if fewer than `batchSize` jobs are available then only the available jobs will be processed in the current batch&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/disable.adoc[`disable`] 
| Disable enqueuing to this queue&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; This method will fail (with an error) if `prepareForDeletion` has already been called on this object&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/drainWaitWhilePausing.adoc[`drainWaitWhilePausing`] 
| Block until all threads waiting for this queue to pause are released&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/enable.adoc[`enable`] 
| Enable enqueuing to this queue&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; This method will fail (with an error) if `prepareForDeletion` has already been called on this object&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/enqueueDeletion.adoc[`enqueueDeletion`] 
| Permanently disable enqueueing from this queue, and enqueue a job that will delete this queue&period; Optionally specify `cleanupFunctor`, which, if supplied, will be invoked immediately prior to this queue&apos;s deletion&period; Optionally specify `completionSignal`, on which (if the calling thread is not processing a job &hyphen; or batch of jobs &hyphen; for this queue) to invoke `arrive` when the queue is deleted&period; Return `true` if the current thread is the thread processing a job (or batch of jobs), and `false` otherwise&period; Note that if `completionSignal` is supplied, a return status of `false` typically indicates that `completionSignal&hyphen;&gt;wait()` should be invoked from the calling function&apos;, while a return status of `true` indicates this is an attempt to delete the queue from within a job being processed on the queue (so waiting on the queue&apos;s deletion would result in a dead&hyphen;lock)&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/executeFront.adoc[`executeFront`] 
| Execute the `Job` at the front of this queue, dequeue the `Job`, and if the queue is not paused schedule a callback from the associated thread pool&period; The behavior is undefined if this queue is empty&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/initiatePause.adoc[`initiatePause`] 
| Initiate the pausing of this queue, prevent jobs from being executed on this queue (excluding the currently&hyphen;executing job &hyphen; or batch of jobs &hyphen; if there is one), and prevent the queue from being deleted&period; Return 0 on success, and a non&hyphen;zero value if the queue is already paused or is being paused or deleted by another thread&period; The behavior is undefined unless, after a successful invocation of `initiatePause`, `waitWhilePausing` is invoked (to complete the pause operation and allow the queue to, potentially, be deleted)&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/isDrained.adoc[`isDrained`] 
| Report whether all jobs in this queue are finished&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/isEnabled.adoc[`isEnabled`] 
| Report whether enqueuing to this object is enabled&period; This object is constructed with enqueuing enabled&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/isPaused.adoc[`isPaused`] 
| Report whether this object is paused&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/length.adoc[`length`] 
| Return an instantaneous snapshot of the length of this queue&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/pushBack.adoc[`pushBack`] 
| Enqueue the specified `functor` at the end of this queue&period; Return 0 on success, and a non&hyphen;zero value if enqueuing is disabled&period; The value of `functor` becomes unspecified but valid, and its allocator remains unchanged&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/pushFront.adoc[`pushFront`] 
| Add the specified `functor` at the front of this queue&period; Return 0 on success, and a non&hyphen;zero value if enqueuing is disabled&period; The value of `functor` becomes unspecified but valid, and its allocator remains unchanged&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/reset.adoc[`reset`] 
| Reset this queue to its initial state&period; The behavior is undefined unless this queue&apos;s lock is in an unlocked state&period; After this method returns, the object is ready for use as though it were a new object&period; Note that this method is not thread&hyphen;safe and is used by the object pool contained within `&ast;d&lowbar;multiQueueThreadPool&lowbar;p`&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/resume.adoc[`resume`] 
| Allow jobs on the queue to begin executing&period; Return 0 on success, and a non&hyphen;zero value if the queue is not paused or `!d&lowbar;list&period;empty()` and the associated thread pool fails to enqueue a job&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/setBatchSize.adoc[`setBatchSize`] 
| Configure this queue to process jobs in groups of the specified `batchSize` (see &lcub;`Job Execution Batch Size`&rcub;)&period; When a thread is selecting jobs for processing, if fewer than `batchSize` jobs are available then only the available jobs will be processed in the current batch&period; The behavior is undefined unless `1 &lt;&equals; batchSize`&period; Note that the initial value for the execution batch size is 1 for all queues&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/waitWhilePausing.adoc[`waitWhilePausing`] 
| Wait until any currently&hyphen;executing job on the queue completes and the queue is paused&period; Note that pausing differs from `disable` in that (1) `pause` stops processing for a queue, and (2) does _not_ prevent additional jobs from being enqueued&period; The behavior of this method is undefined unless it is invoked after a successful `initiatePause` invocation&period;
| xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;MultiQueueThreadPool&lowbar;Queue, UsesBslmaAllocator&gt;`] 
| Declare that this type uses a `bslma` allocator&period;
|===



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