BloombergLP::bdlmt::ThreadPool::ThreadPool

Construct a thread pool with variable worker count.

Synopsis

Declared in <bdlmt_threadpool.h>

ThreadPool(
    bslmt::ThreadAttributes const& threadAttributes,
    int minThreads,
    int maxThreads,
    int maxIdleTime,
    bslma::Allocator* basicAllocator = 0);

Description

Construct a thread pool with the specified threadAttributes, the specified minThreads minimum number of threads, the specified maxThreads maximum number of threads, and the specified maxIdleTime idle time (in milliseconds) after which a thread may be considered for destruction. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The name used for created threads is threadAttributes.threadName() if not empty, otherwise "bdl.ThreadPool". The behavior is undefined unless 0 <= minThreads, minThreads <= maxThreads, and 0 <= maxIdleTime.

Parameters

NameDescription
threadAttributesattributes used when creating worker threads
minThreadsminimum number of worker threads
maxThreadsmaximum number of worker threads
maxIdleTimeidle time in milliseconds before a thread may exit
basicAllocatormemory allocator; null uses the default