8#ifndef INCLUDED_BDLMT_THREADPOOL
9#define INCLUDED_BDLMT_THREADPOOL
398#include <bdlf_bind.h>
421#include <bsl_deque.h>
422#if defined(BSLS_PLATFORM_OS_UNIX)
423 #include <bsl_csignal.h>
425#include <bsl_functional.h>
426#include <bsl_string.h>
428#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
434#ifndef BDE_OMIT_INTERNAL_DEPRECATED
444struct ThreadPoolWaitNode;
484 const int d_maxThreads;
489 const int d_minThreads;
505 int d_numActiveThreads;
529#if defined(BSLS_PLATFORM_OS_UNIX)
538 static const char s_defaultThreadName[16];
552 void doEnqueueJob(
const Job& job);
563 void wakeThreadIfNeeded();
569 int startThreadIfNeeded();
571#if defined(BSLS_PLATFORM_OS_UNIX)
578 int startNewThread();
792 return enqueueJob(bdlf::BindUtil::bindR<void>(function, userData));
818 return d_createFailures;
830 return d_maxIdleTime;
Definition bdlm_metricsregistry.h:306
Definition bdlm_metricsregistry.h:197
Definition bdlmt_threadpool.h:461
double percentBusy() const
bsl::function< void()> Job
Definition bdlmt_threadpool.h:465
int threadFailures() const
Return the number of times that thread creation failed.
Definition bdlmt_threadpool.h:816
int enqueueJob(const Job &functor)
ThreadPool(const bslmt::ThreadAttributes &threadAttributes, int minThreads, int maxThreads, int maxIdleTime, bslma::Allocator *basicAllocator=0)
int maxThreads() const
Definition bdlmt_threadpool.h:810
int enqueueJob(bslmf::MovableRef< Job > functor)
ThreadPool(const bslmt::ThreadAttributes &threadAttributes, int minThreads, int maxThreads, bsls::TimeInterval maxIdleTime, const bsl::string_view &threadPoolName, bdlm::MetricsRegistry *metricsRegistry, bslma::Allocator *basicAllocator=0)
int minThreads() const
Definition bdlmt_threadpool.h:804
int numPendingJobs() const
BSLMF_NESTED_TRAIT_DECLARATION(ThreadPool, bslma::UsesBslmaAllocator)
ThreadPool(const bslmt::ThreadAttributes &threadAttributes, int minThreads, int maxThreads, bsls::TimeInterval maxIdleTime, bslma::Allocator *basicAllocator=0)
bsls::TimeInterval maxIdleTimeInterval() const
Definition bdlmt_threadpool.h:828
int maxIdleTime() const
Definition bdlmt_threadpool.h:822
int numWaitingThreads() const
Return the number of threads that are currently waiting for a job.
int numActiveThreads() const
Return the number of threads that are currently processing a job.
friend void * ThreadPoolEntry(void *)
Entry point for processing threads.
int enabled() const
Return the state (enabled or not) of the thread pool.
Definition bdlmt_threadpool.h:798
double resetPercentBusy()
ThreadPool(const bslmt::ThreadAttributes &threadAttributes, int minThreads, int maxThreads, int maxIdleTime, const bsl::string_view &threadPoolName, bdlm::MetricsRegistry *metricsRegistry, bslma::Allocator *basicAllocator=0)
~ThreadPool()
Call shutdown() and destroy this thread pool.
Definition bslstl_stringview.h:471
Definition bslstl_deque.h:814
Forward declaration.
Definition bslstl_function.h:946
Definition bslma_allocator.h:545
Definition bslmf_movableref.h:752
Definition bslmt_condition.h:220
Definition bslmt_mutex.h:317
Definition bslmt_threadattributes.h:361
Definition bsls_atomic.h:896
Definition bsls_atomic.h:744
Definition bsls_atomic.h:1362
Definition bsls_timeinterval.h:307
BSLS_KEYWORD_CONSTEXPR_CPP14 bsls::Types::Int64 totalMilliseconds() const
Definition bsls_timeinterval.h:1459
void(* bcep_ThreadPoolJobFunc)(void *)
Definition bdlmt_threadpool.h:438
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition bdlmt_eventscheduler.h:550
void(* ThreadPoolJobFunc)(void *)
Definition bdlmt_threadpool.h:451
void * ThreadPoolEntry(void *)
Entry point for processing threads.
Definition bslma_usesbslmaallocator.h:344