[#BloombergLP-bdlmt-FixedThreadPool] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlmt.adoc[bdlmt]::FixedThreadPool :relfileprefix: ../../ :mrdocs: This class implements a thread pool used for concurrently executing multiple user‐defined functions ("jobs"). == Synopsis Declared in `<bdlmt_fixedthreadpool.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class FixedThreadPool; ---- == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlmt/FixedThreadPool/Job.adoc[`Job`] | Defines a type alias for the job functor type. | xref:BloombergLP/bdlmt/FixedThreadPool/Queue.adoc[`Queue`] | Defines a type alias for the bounded job queue type. |=== == Enums [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlmt/FixedThreadPool/_04enum-0c.adoc[`Unnamed enum`] | Status codes returned by queue operations. | xref:BloombergLP/bdlmt/FixedThreadPool/_04enum-08.adoc[`Unnamed enum`] | Thread‐pool operational states. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlmt/FixedThreadPool/2constructor-03.adoc[`FixedThreadPool`] [.small]#[constructor]# | Constructors | xref:BloombergLP/bdlmt/FixedThreadPool/2destructor.adoc[`~FixedThreadPool`] [.small]#[destructor]# | Remove all pending jobs from the queue without executing them, block until all currently running jobs complete, and then destroy this thread pool. | xref:BloombergLP/bdlmt/FixedThreadPool/disable.adoc[`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. | xref:BloombergLP/bdlmt/FixedThreadPool/drain.adoc[`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. | xref:BloombergLP/bdlmt/FixedThreadPool/enable.adoc[`enable`] | Enable queuing into this pool. If the queue is not enqueue disabled, this call has no effect. | xref:BloombergLP/bdlmt/FixedThreadPool/enqueueJob-04.adoc[`enqueueJob`] | `enqueueJob` overloads | xref:BloombergLP/bdlmt/FixedThreadPool/isEnabled.adoc[`isEnabled`] | Return `true` if enqueuing jobs is enabled on this thread pool, and `false` otherwise. | xref:BloombergLP/bdlmt/FixedThreadPool/isStarted.adoc[`isStarted`] | Return `true` if `numThreads()` are started on this threadpool and `false` otherwise (indicating that 0 threads are started on this thread pool.) | xref:BloombergLP/bdlmt/FixedThreadPool/numActiveThreads.adoc[`numActiveThreads`] | Return a snapshot of the number of threads that are currently processing a job for this threadpool. | xref:BloombergLP/bdlmt/FixedThreadPool/numPendingJobs.adoc[`numPendingJobs`] | Return a snapshot of the number of jobs currently enqueued to be processed by thread pool. | xref:BloombergLP/bdlmt/FixedThreadPool/numThreads.adoc[`numThreads`] | Return the number of threads passed to this thread pool at construction. | xref:BloombergLP/bdlmt/FixedThreadPool/numThreadsStarted.adoc[`numThreadsStarted`] | Return a snapshot of the number of threads currently started by this thread pool. | xref:BloombergLP/bdlmt/FixedThreadPool/queueCapacity.adoc[`queueCapacity`] | Return the capacity of the queue used to enqueue jobs by this thread pool. | xref:BloombergLP/bdlmt/FixedThreadPool/shutdown.adoc[`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()`. | xref:BloombergLP/bdlmt/FixedThreadPool/start.adoc[`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. | xref:BloombergLP/bdlmt/FixedThreadPool/stop.adoc[`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()`. | xref:BloombergLP/bdlmt/FixedThreadPool/tryEnqueueJob-0d.adoc[`tryEnqueueJob`] | `tryEnqueueJob` overloads |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#