#include <thread_pool.h>
Definition at line 24 of file thread_pool.h.
Botan::Thread_Pool::Thread_Pool |
( |
size_t |
pool_size = 0 | ) |
|
Initialize a thread pool with some number of threads
- Parameters
-
pool_size | number of threads in the pool, if 0 then some default value is chosen |
Definition at line 21 of file thread_pool.cpp.
References Botan::OS::get_cpu_available().
40 for(
size_t i = 0; i != pool_size; ++i)
42 m_workers.push_back(std::thread(&Thread_Pool::worker_thread,
this));
size_t BOTAN_TEST_API get_cpu_available()
Botan::Thread_Pool::~Thread_Pool |
( |
| ) |
|
|
inline |
Botan::Thread_Pool::Thread_Pool |
( |
const Thread_Pool & |
| ) |
|
|
delete |
void Botan::Thread_Pool::queue_thunk |
( |
std::function< void()> |
fn | ) |
|
Definition at line 66 of file thread_pool.cpp.
68 std::unique_lock<std::mutex> lock(m_mutex);
71 throw Invalid_State(
"Cannot add work after thread pool has shut down");
73 m_tasks.push_back(fn);
74 m_more_tasks.notify_one();
template<class F , class... Args>
auto Botan::Thread_Pool::run |
( |
F && |
f, |
|
|
Args &&... |
args |
|
) |
| -> std::future<typename std::result_of<F(Args...)>::type>
|
|
inline |
Definition at line 57 of file thread_pool.h.
References Botan::F, and type.
Referenced by Botan::XMSS_PrivateKey::tree_hash().
59 typedef typename std::result_of<
F(Args...)>
::type return_type;
61 auto future_work = std::bind(std::forward<F>(f), std::forward<Args>(args)...);
62 auto task = std::make_shared<std::packaged_task<return_type ()>>(future_work);
63 auto future_result = task->get_future();
void queue_thunk(std::function< void()>)
void Botan::Thread_Pool::shutdown |
( |
| ) |
|
Definition at line 46 of file thread_pool.cpp.
49 std::unique_lock<std::mutex> lock(m_mutex);
51 if(m_shutdown ==
true)
56 m_more_tasks.notify_all();
59 for(
auto&& thread : m_workers)
size_t Botan::Thread_Pool::worker_count |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following files: