Skip to content
Snippets Groups Projects
Commit 311a8981 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

thread pool: add computation, io pools

parent 04850e17
No related branches found
No related tags found
No related merge requests found
...@@ -26,12 +26,29 @@ ...@@ -26,12 +26,29 @@
namespace dht { namespace dht {
constexpr const size_t IO_THREADS_MAX {64};
struct ThreadPool::ThreadState struct ThreadPool::ThreadState
{ {
std::thread thread {}; std::thread thread {};
std::atomic_bool run {true}; std::atomic_bool run {true};
}; };
ThreadPool&
ThreadPool::computation()
{
static ThreadPool pool;
return pool;
}
ThreadPool&
ThreadPool::io()
{
static ThreadPool pool(IO_THREADS_MAX);
return pool;
}
ThreadPool::ThreadPool(size_t maxThreads) : maxThreads_(maxThreads) ThreadPool::ThreadPool(size_t maxThreads) : maxThreads_(maxThreads)
{ {
threads_.reserve(maxThreads_); threads_.reserve(maxThreads_);
......
...@@ -29,10 +29,8 @@ namespace dht { ...@@ -29,10 +29,8 @@ namespace dht {
class ThreadPool { class ThreadPool {
public: public:
static ThreadPool& instance() { static ThreadPool& computation();
static ThreadPool pool; static ThreadPool& io();
return pool;
}
ThreadPool(); ThreadPool();
ThreadPool(size_t maxThreads); ThreadPool(size_t maxThreads);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment