#include <thread_pool.hpp>
Definition at line 17 of file thread_pool.hpp.
◆ task_type
◆ thread_pool() [1/3]
thread_pool::thread_pool |
( |
std::size_t |
thread_count = std::thread::hardware_concurrency() , |
|
|
int |
phy_prio = 10 |
|
) |
| |
|
inlineexplicit |
Definition at line 23 of file thread_pool.hpp.
25 struct sched_param thread_param;
26 thread_param.sched_priority = phy_prio;
29 spdlog::info(
"Launching phy thread with realtime scheduling priority {}", thread_param.sched_priority );
32 int error = pthread_setschedparam(
m_workers.back().native_handle(), SCHED_RR, &thread_param );
35 spdlog::error(
"Cannot set phy thread priority to realtime: {}. Thread will run at default priority.", strerror(error));
std::size_t thread_count() const
std::vector< std::thread > m_workers
◆ ~thread_pool()
thread_pool::~thread_pool |
( |
| ) |
|
|
inline |
◆ thread_pool() [2/3]
◆ thread_pool() [3/3]
◆ active_count()
std::size_t thread_pool::active_count |
( |
| ) |
const |
|
inline |
◆ clear()
void thread_pool::clear |
( |
| ) |
|
|
inline |
Definition at line 76 of file thread_pool.hpp.
78 std::unique_lock<std::mutex> lock{
m_mutex };
std::queue< task_type > m_tasks
◆ join()
void thread_pool::join |
( |
| ) |
|
|
inline |
Definition at line 86 of file thread_pool.hpp.
92 if (thread.joinable()) {
std::condition_variable m_notifier
std::atomic< bool > m_stop
◆ next_task()
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ push()
template<class Func , class... Args>
auto thread_pool::push |
( |
Func && |
fn, |
|
|
Args &&... |
args |
|
) |
| |
|
inline |
Definition at line 55 of file thread_pool.hpp.
57 using return_type =
typename std::result_of<Func(Args...)>::type;
59 auto task{ std::make_shared<std::packaged_task<return_type()>>(
60 std::bind(std::forward<Func>(fn), std::forward<Args>(args)...)
63 auto future{ task->get_future() };
64 std::unique_lock<std::mutex> lock{
m_mutex };
◆ thread_count()
std::size_t thread_pool::thread_count |
( |
| ) |
const |
|
inline |
◆ thread_loop()
void thread_pool::thread_loop |
( |
| ) |
|
|
inlineprivate |
◆ m_active
std::atomic<std::size_t> thread_pool::m_active { 0 } |
|
private |
◆ m_mutex
std::mutex thread_pool::m_mutex |
|
private |
◆ m_notifier
std::condition_variable thread_pool::m_notifier |
|
private |
◆ m_stop
std::atomic<bool> thread_pool::m_stop { false } |
|
private |
◆ m_tasks
◆ m_workers
std::vector<std::thread> thread_pool::m_workers |
|
private |
The documentation for this class was generated from the following file: