|
CARLA
|
A thread pool based on Boost.Asio's io context. More...
#include <ThreadPool.h>
Inheritance diagram for carla::ThreadPool:Public Member Functions | |
| void | AsyncRun () |
| Launch threads to run tasks asynchronously. | |
| void | AsyncRun (size_t worker_threads) |
| Launch threads to run tasks asynchronously. | |
| auto & | io_context () |
| Return the underlying io_context. | |
| template<typename FunctorT , typename ResultT = typename std::invoke_result_t<FunctorT()>> | |
| std::future< ResultT > | Post (FunctorT &&functor) |
| Post a task to the pool. | |
| void | Run () |
| Run tasks in this thread. | |
| void | RunFor (time_duration duration) |
| Run tasks in this thread for an specific duration. | |
| void | Stop () |
| Stop the ThreadPool and join all its threads. | |
| ThreadPool () | |
| ~ThreadPool () | |
| Stops the ThreadPool and joins all its threads. | |
Private Attributes | |
| boost::asio::io_context | _io_context |
| boost::asio::executor_work_guard< boost::asio::io_context::executor_type > | _work_to_do |
| ThreadGroup | _workers |
Additional Inherited Members | |
Private Member Functions inherited from carla::NonCopyable | |
| NonCopyable ()=default | |
| NonCopyable (const NonCopyable &)=delete | |
| NonCopyable (NonCopyable &&)=delete | |
| NonCopyable & | operator= (const NonCopyable &)=delete |
| NonCopyable & | operator= (NonCopyable &&)=delete |
A thread pool based on Boost.Asio's io context.
Definition at line 25 of file ThreadPool.h.
|
inline |
Definition at line 28 of file ThreadPool.h.
|
inline |
Stops the ThreadPool and joins all its threads.
Definition at line 31 of file ThreadPool.h.
References Stop().
|
inline |
Launch threads to run tasks asynchronously.
Launch specific number of threads if worker_threads is provided, otherwise use all available hardware concurrency.
Definition at line 59 of file ThreadPool.h.
References AsyncRun().
Referenced by AsyncRun().
|
inline |
Launch threads to run tasks asynchronously.
Launch specific number of threads if worker_threads is provided, otherwise use all available hardware concurrency.
Definition at line 54 of file ThreadPool.h.
References _workers, carla::ThreadGroup::CreateThreads(), and Run().
Referenced by carla::multigpu::Router::AsyncRun(), carla::streaming::Client::AsyncRun(), and carla::streaming::Server::AsyncRun().
|
inline |
Return the underlying io_context.
Definition at line 36 of file ThreadPool.h.
References _io_context.
Referenced by carla::multigpu::Router::Router(), and carla::streaming::Client::Subscribe().
|
inline |
Post a task to the pool.
Definition at line 44 of file ThreadPool.h.
References _io_context, and carla::MoveHandler().
|
inline |
Run tasks in this thread.
Definition at line 66 of file ThreadPool.h.
References _io_context.
Referenced by AsyncRun(), carla::streaming::Client::Run(), and carla::streaming::Server::Run().
|
inline |
Run tasks in this thread for an specific duration.
Definition at line 74 of file ThreadPool.h.
References _io_context, and carla::time_duration::to_chrono().
|
inline |
Stop the ThreadPool and join all its threads.
Definition at line 79 of file ThreadPool.h.
References _io_context, _work_to_do, _workers, and carla::ThreadGroup::JoinAll().
Referenced by carla::multigpu::Router::Stop(), carla::streaming::Client::Stop(), carla::streaming::Client::~Client(), carla::multigpu::Secondary::~Secondary(), carla::streaming::Server::~Server(), and ~ThreadPool().
|
private |
Definition at line 87 of file ThreadPool.h.
Referenced by io_context(), Post(), Run(), RunFor(), and Stop().
|
private |
Definition at line 89 of file ThreadPool.h.
Referenced by Stop().
|
private |
Definition at line 91 of file ThreadPool.h.
Referenced by AsyncRun(), and Stop().