8#ifndef META_OCEAN_BASE_THREAD_POOL_H
9#define META_OCEAN_BASE_THREAD_POOL_H
62 inline bool isBusy()
const;
126 inline size_t size()
const;
This class implements a recursive lock object.
Definition Lock.h:31
This class implements a scoped lock object for recursive lock objects.
Definition Lock.h:147
This class implements a signal.
Definition Signal.h:31
Thread(const std::string &name=std::string())
Creates a new thread object.
void invoke(Function &&function)
Sets the thread function.
PoolThread(const std::string &name)
Creates a new thread object.
Lock lock_
Thread lock.
Definition ThreadPool.h:86
void threadRun() override
Thread run function.
bool isBusy() const
Returns whether this thread is currently busy.
Definition ThreadPool.h:202
Signal signal_
Internal signal handling the internal thread execution.
Definition ThreadPool.h:80
Function function_
The function that is invoked in this thread.
Definition ThreadPool.h:83
~PoolThread() override
Destructs a thread object.
size_t capacity_
Maximal pool capacity, with range [1, infinity).
Definition ThreadPool.h:173
size_t size() const
Returns the number of currently busy/active threads in this pool.
Definition ThreadPool.h:215
FunctionQueue pendingFunctions_
The pending functions.
Definition ThreadPool.h:170
bool isEmpty() const
Returns whether the ThreadPool has completed all jobs that have been submitted.
Definition ThreadPool.h:229
size_t poolThreadIdCounter_
The counter for pool thread ids.
Definition ThreadPool.h:176
size_t capacity() const
Returns the maximal number of thread objects allowed inside this pool.
Definition ThreadPool.h:209
ThreadPool()=default
Creates a new thread pool object.
PoolThreads idlePoolThreads_
The idle pool threads.
Definition ThreadPool.h:167
Lock lock_
Pool lock.
Definition ThreadPool.h:179
std::function< void()> Function
Definition of a caller function without return parameter.
Definition ThreadPool.h:36
std::queue< Function > FunctionQueue
Definition of a queue holding functions.
Definition ThreadPool.h:102
bool invoke(Function &&function)
Invokes a function on one of the free threads of this pool.
bool setCapacity(const size_t capacity)
Defines the maximal number of thread objects existing concurrently.
~ThreadPool() override
Destructs a thread pool.
void threadRun() override
Thread run function.
PoolThreads busyPoolThreads_
The busy pool threads.
Definition ThreadPool.h:164
size_t pending() const
Returns the number of pending functions.
Definition ThreadPool.h:222
std::vector< UniquePoolThread > PoolThreads
Definition of a vector holding pool threads.
Definition ThreadPool.h:97
std::unique_ptr< PoolThread > UniquePoolThread
Definition of a unique pointer holding a pool thread.
Definition ThreadPool.h:92
ThreadPoolSingleton()
Protected default constructor.
The namespace covering the entire Ocean framework.
Definition Accessor.h:15