|
RADLib
RADical C++ application framework
|
Simple worker thread pool that reports completion through RADFuture. More...
#include <RADCore.h>
Inheritance diagram for RADCore::RADThreadPool:
Collaboration diagram for RADCore::RADThreadPool:Public Member Functions | |
| RADThreadPool (size_t threadCount=std::thread::hardware_concurrency()) | |
| Creates a pool with threadCount workers. More... | |
| ~RADThreadPool () override | |
| Stops workers after queued tasks complete. More... | |
| RADFuture | submit (EventLoop &completionLoop, std::function< RADVariant()> task) |
| Submits task and posts completion wakeup to completionLoop. More... | |
| template<typename F > | |
| auto | submitTyped (EventLoop &completionLoop, F &&task) -> RADFutureT< std::invoke_result_t< F >> |
| Submits a typed task and posts completion wakeup to completionLoop. More... | |
| template<typename F > | |
| auto | submitCancellable (EventLoop &completionLoop, RADCancellationToken token, F &&task) -> RADFutureT< std::invoke_result_t< F, RADCancellationToken >> |
| Submits a typed task that receives a cancellation token. More... | |
| void | waitForDone () |
| Blocks until queued and active tasks are complete. More... | |
| size_t | threadCount () const |
| Returns number of worker threads. More... | |
Public Member Functions inherited from RADCore::RADObject | |
| RADObject () | |
| Creates a RADObject bound to the current thread. More... | |
| virtual | ~RADObject () |
| Disconnects tracked event links and releases lifetime token. More... | |
| void | registerLink (const ConnectionRecord &record) |
| Registers a connection for cleanup when this object is destroyed. More... | |
| std::thread::id | threadId () const |
| Returns the thread id this object is currently associated with. More... | |
| EventLoop * | associatedEventLoop () const |
| Returns the associated event loop, if any. More... | |
| ThreadAffinity | threadAffinity () const |
| Returns both thread id and associated loop atomically. More... | |
| std::weak_ptr< void > | lifetimeToken () const |
| Returns a weak token used to drop queued callbacks after destruction. More... | |
| void | moveToThread (std::thread::id tId, EventLoop *loop=nullptr) |
| Moves the object's affinity to tId and optional loop. More... | |
Simple worker thread pool that reports completion through RADFuture.
|
explicit |
Creates a pool with threadCount workers.
|
override |
Stops workers after queued tasks complete.
| RADFuture RADCore::RADThreadPool::submit | ( | EventLoop & | completionLoop, |
| std::function< RADVariant()> | task | ||
| ) |
Submits task and posts completion wakeup to completionLoop.
|
inline |
Submits a typed task that receives a cancellation token.
|
inline |
Submits a typed task and posts completion wakeup to completionLoop.
| size_t RADCore::RADThreadPool::threadCount | ( | ) | const |
Returns number of worker threads.
| void RADCore::RADThreadPool::waitForDone | ( | ) |
Blocks until queued and active tasks are complete.