This private class provides a thread-safe, lightweight job queue.
Declared in <bdlmt_multiqueuethreadpool.h>
class MultiQueueThreadPool_Queue;
| Name | Description |
|---|---|
Job | Defines a type alias for the job functor type. |
| Name | Description |
|---|---|
MultiQueueThreadPool_Queue [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. |
~MultiQueueThreadPool_Queue [destructor] | Destroy this queue. |
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. |
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. |
drainWaitWhilePausing | Block until all threads waiting for this queue to pause are released. |
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. |
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). |
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. |
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). |
isDrained | Report whether all jobs in this queue are finished. |
isEnabled | Report whether enqueuing to this object is enabled. This object is constructed with enqueuing enabled. |
isPaused | Report whether this object is paused. |
length | Return an instantaneous snapshot of the length of this queue. |
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. |
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. |
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. |
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. |
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. |
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. |
operator BloombergLP::bslmf::NestedTraitDeclaration<MultiQueueThreadPool_Queue, UsesBslmaAllocator> | Declare that this type uses a bslma allocator. |