BloombergLP::bdlmt::MultipriorityThreadPool

Thread pool that executes jobs according to integral priorities.

Synopsis

Declared in <bdlmt_multiprioritythreadpool.h>

class MultipriorityThreadPool;

Description

This class implements a thread-enabled, integrally-prioritized thread-pool mechanism used for concurrently executing multiple user-defined "jobs" supplied as either conventional C-style functions taking an optional void * data argument, or as more flexible functor objects.

Type Aliases

NameDescription
ThreadFunctor Type alias for a nullary function object that returns void.

Enums

NameDescription
Unnamed enum Maximum number of distinct job priorities supported by this pool.

Member Functions

NameDescription
MultipriorityThreadPool [constructor]Constructors
~MultipriorityThreadPool [destructor]Remove (cancel) all pending jobs and destroy this multi-priority thread pool. The behavior is undefined unless this thread pool is stopped.
disableQueue Disable enqueuing of jobs to this thread pool.
drainJobs Block until all executing and pending jobs complete.
enableQueue Enable enqueuing of jobs to this thread pool.
enqueueJob enqueueJob overloads
isEnabled Return true if the enqueuing of new jobs is enabled for this multi-priority thread pool, and false otherwise.
isStarted Return true if all numThreads() worker threads (specified at construction) have been created for this multi-priority thread pool, and false otherwise.
isSuspended Return true if the threads of this multi-priority thread pool are currently suspended from processing jobs, and false otherwise.
numActiveThreads Return a snapshot of the number of threads currently processing jobs.
numPendingJobs Return a snapshot of the number of jobs currently enqueued to be processed by this multi-priority thread pool, but are not yet running.
numPriorities Return the fixed number of priorities, specified at construction, that this multi-priority thread pool supports.
numStartedThreads Return the number of threads that have been started for this multi-priority thread pool. Note that they may be currently suspended.
numThreads Returns the fixed number of threads, specified at construction, that are started by this multi-priority thread pool.
removeJobs Remove all pending jobs from the queue of this thread pool.
resumeProcessing Resume job processing if this thread pool is suspended.
shutdown Disable the enqueuing of new jobs to this multi-priority thread pool, cancel all pending jobs, and stop all worker threads.
startThreads Create and start the worker threads of this thread pool.
stopThreads Destroy all worker threads after active jobs complete.
suspendProcessing Put this thread pool into the suspended state.
operator BloombergLP::bslmf::NestedTraitDeclaration<MultipriorityThreadPool, UsesBslmaAllocator> Declare that this type uses a bslma allocator.