This class implements a thread pool used for concurrently executing multiple user‐defined functions ("jobs").

Synopsis

Declared in <bdlmt_fixedthreadpool.h>

class FixedThreadPool;

Type Aliases

Name

Description

Job

Defines a type alias for the job functor type.

Queue

Defines a type alias for the bounded job queue type.

Enums

Name

Description

Unnamed enum

Status codes returned by queue operations.

Unnamed enum

Thread‐pool operational states.

Member Functions

Name

Description

FixedThreadPool [constructor]

Constructors

~FixedThreadPool [destructor]

Remove all pending jobs from the queue without executing them, block until all currently running jobs complete, and then destroy this thread pool.

disable

Disable enqueueing into this pool. All subsequent invocations of enqueueJob or tryEnqueueJob will fail immediately. All blocked invocations of enqueueJob will fail immediately. If the pool is already enqueue disabled, this method has no effect. Note that this method has no effect on jobs currently in the pool.

drain

Wait until the underlying queue is empty without disabling this pool (and may thus wait indefinitely), and then wait until all executing jobs complete. If the thread pool was not already started (isStarted() is false), this method has no effect. Note that if any jobs are submitted concurrently with this method, this method may or may not wait until they have also completed.

enable

Enable queuing into this pool. If the queue is not enqueue disabled, this call has no effect.

enqueueJob

enqueueJob overloads

isEnabled

Return true if enqueuing jobs is enabled on this thread pool, and false otherwise.

isStarted

Return true if numThreads() are started on this threadpool and false otherwise (indicating that 0 threads are started on this thread pool.)

numActiveThreads

Return a snapshot of the number of threads that are currently processing a job for this threadpool.

numPendingJobs

Return a snapshot of the number of jobs currently enqueued to be processed by thread pool.

numThreads

Return the number of threads passed to this thread pool at construction.

numThreadsStarted

Return a snapshot of the number of threads currently started by this thread pool.

queueCapacity

Return the capacity of the queue used to enqueue jobs by this thread pool.

shutdown

Disable enqueuing jobs on this thread pool, cancel all pending jobs, wait until all active jobs complete, and join all processing threads. If the thread pool was not already started (isStarted() is false), this method has no effect. At the completion of this method, false == isStarted().

start

Spawn threads until there are numThreads() processing threads. On success, enable enqueuing and return 0. Otherwise, join all threads (ensuring false == isStarted()) and return ‐1. If the thread pool was already started (isStarted() is true), this method has no effect.

stop

Disable enqueuing jobs on this thread pool, wait until all active and pending jobs complete, and join all processing threads. If the thread pool was not already started (isStarted() is false), this method has no effect. At the completion of this method, false == isStarted().

tryEnqueueJob

tryEnqueueJob overloads

Created with MrDocs