#include <BoundedThreadPool.hpp>
Definition at line 25 of file BoundedThreadPool.hpp.
◆ BoundedThreadPool() [1/3]
| BoundedThreadPool::BoundedThreadPool |
( |
int |
n_threads | ) |
|
|
inlineexplicit |
◆ BoundedThreadPool() [2/3]
| BoundedThreadPool::BoundedThreadPool |
( |
int |
n_threads, |
|
|
int |
limit |
|
) |
| |
|
inlineexplicit |
◆ BoundedThreadPool() [3/3]
| BoundedThreadPool::BoundedThreadPool |
( |
| ) |
|
|
inline |
◆ ~BoundedThreadPool()
| BoundedThreadPool::~BoundedThreadPool |
( |
| ) |
|
|
inline |
Definition at line 136 of file BoundedThreadPool.hpp.
137 {
139 b_running = false;
140 cnd_buffer_empty.notify_all();
142 }
void wait_for_completion()
◆ init()
| void BoundedThreadPool::init |
( |
int |
n_threads, |
|
|
int |
limit |
|
) |
| |
|
inline |
Definition at line 108 of file BoundedThreadPool.hpp.
109 {
110 int n_threads_max = std::thread::hardware_concurrency();
112 {
114 }
115 else
116 {
118 }
120 b_running = true;
121 create_threads();
122 }
◆ join_threads()
| void BoundedThreadPool::join_threads |
( |
| ) |
|
|
inline |
◆ push_task() [1/2]
template<typename T >
| void BoundedThreadPool::push_task |
( |
const T & |
task | ) |
|
|
inline |
Definition at line 77 of file BoundedThreadPool.hpp.
78 {
79 std::unique_lock<std::mutex> lock(mtx_queue);
80 cnd_buffer_full.wait(lock, [this]
81 {
return ((
int)tasks.size() <
limit); });
82 tasks.push(std::function<void()>(task));
83 cnd_buffer_empty.notify_one();
84 }
◆ push_task() [2/2]
template<typename T , typename... A>
| void BoundedThreadPool::push_task |
( |
const T & |
task, |
|
|
const A &... |
args |
|
) |
| |
|
inline |
Definition at line 87 of file BoundedThreadPool.hpp.
88 {
90 { task(args...); });
91 }
void push_task(const T &task)
◆ wait_for_completion()
| void BoundedThreadPool::wait_for_completion |
( |
| ) |
|
|
inline |
Definition at line 93 of file BoundedThreadPool.hpp.
94 {
95 std::unique_lock<std::mutex> lock(mtx_queue);
96 cnd_buffer_full.wait(lock, [this]
97 { return tasks.empty(); });
98 }
◆ limit
| int BoundedThreadPool::limit |
◆ n_threads
| int BoundedThreadPool::n_threads |
The documentation for this class was generated from the following file: