[#BloombergLP-bdlmt-MultiQueueThreadPool_Queue] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlmt.adoc[bdlmt]::MultiQueueThreadPool_Queue :relfileprefix: ../../ :mrdocs: This private class provides a thread‐safe, lightweight job queue. == Synopsis Declared in `<bdlmt_multiqueuethreadpool.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class MultiQueueThreadPool_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. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/2constructor-0508.adoc[`MultiQueueThreadPool_Queue`] [.small]#[constructor]# | Create a `MultiQueueThreadPool_Queue` with an initial capacity of 0 and initialized to use the specified `multiQueueThreadPool` to track aggregate values (e.g., the number of active queues) and to obtain the thread pool used to execute jobs that are appended to this queue. Optionally specify a `basicAllocator` used to supply memory. If `basicAllocator` is 0, the default memory allocator is used. | xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/2destructor.adoc[`~MultiQueueThreadPool_Queue`] [.small]#[destructor]# | Destroy this queue. | xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/batchSize.adoc[`batchSize`] | Return an instantaneous snapshot of the execution batch size (see {`Job Execution Batch Size`}). 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. | xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/disable.adoc[`disable`] | Disable enqueuing to this queue. Return 0 on success, and a non‐zero value otherwise. This method will fail (with an error) if `prepareForDeletion` has already been called on this object. | xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/drainWaitWhilePausing.adoc[`drainWaitWhilePausing`] | Block until all threads waiting for this queue to pause are released. | xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/enable.adoc[`enable`] | Enable enqueuing to this queue. Return 0 on success, and a non‐zero value otherwise. This method will fail (with an error) if `prepareForDeletion` has already been called on this object. | xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/enqueueDeletion.adoc[`enqueueDeletion`] | Permanently disable enqueueing from this queue, and enqueue a job that will delete this queue. Optionally specify `cleanupFunctor`, which, if supplied, will be invoked immediately prior to this queue's deletion. Optionally specify `completionSignal`, on which (if the calling thread is not processing a job ‐ or batch of jobs ‐ for this queue) to invoke `arrive` when the queue is deleted. Return `true` if the current thread is the thread processing a job (or batch of jobs), and `false` otherwise. Note that if `completionSignal` is supplied, a return status of `false` typically indicates that `completionSignal‐>wait()` should be invoked from the calling function', 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's deletion would result in a dead‐lock). | 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. The behavior is undefined if this queue is empty. | 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‐executing job ‐ or batch of jobs ‐ if there is one), and prevent the queue from being deleted. Return 0 on success, and a non‐zero value if the queue is already paused or is being paused or deleted by another thread. 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). | xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/isDrained.adoc[`isDrained`] | Report whether all jobs in this queue are finished. | xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/isEnabled.adoc[`isEnabled`] | Report whether enqueuing to this object is enabled. This object is constructed with enqueuing enabled. | xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/isPaused.adoc[`isPaused`] | Report whether this object is paused. | xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/length.adoc[`length`] | Return an instantaneous snapshot of the length of this queue. | xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/pushBack.adoc[`pushBack`] | Enqueue the specified `functor` at the end of this queue. Return 0 on success, and a non‐zero value if enqueuing is disabled. The value of `functor` becomes unspecified but valid, and its allocator remains unchanged. | xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/pushFront.adoc[`pushFront`] | Add the specified `functor` at the front of this queue. Return 0 on success, and a non‐zero value if enqueuing is disabled. The value of `functor` becomes unspecified but valid, and its allocator remains unchanged. | xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/reset.adoc[`reset`] | Reset this queue to its initial state. The behavior is undefined unless this queue's lock is in an unlocked state. After this method returns, the object is ready for use as though it were a new object. Note that this method is not thread‐safe and is used by the object pool contained within `*d_multiQueueThreadPool_p`. | xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/resume.adoc[`resume`] | Allow jobs on the queue to begin executing. Return 0 on success, and a non‐zero value if the queue is not paused or `!d_list.empty()` and the associated thread pool fails to enqueue a job. | xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/setBatchSize.adoc[`setBatchSize`] | Configure this queue to process jobs in groups of the specified `batchSize` (see {`Job Execution Batch Size`}). 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. The behavior is undefined unless `1 <= batchSize`. Note that the initial value for the execution batch size is 1 for all queues. | xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/waitWhilePausing.adoc[`waitWhilePausing`] | Wait until any currently‐executing job on the queue completes and the queue is paused. 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. The behavior of this method is undefined unless it is invoked after a successful `initiatePause` invocation. | xref:BloombergLP/bdlmt/MultiQueueThreadPool_Queue/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<MultiQueueThreadPool_Queue, UsesBslmaAllocator>`] | Declare that this type uses a `bslma` allocator. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#