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 @@
namespace dht {
constexpr const size_t IO_THREADS_MAX {64};
struct ThreadPool::ThreadState
{
std::thread thread {};
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)
{
threads_.reserve(maxThreads_);
......
......@@ -29,10 +29,8 @@ namespace dht {
class ThreadPool {
public:
static ThreadPool& instance() {
static ThreadPool pool;
return pool;
}
static ThreadPool& computation();
static ThreadPool& io();
ThreadPool();
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