thread pool: add minimum size of 4 threads

rationale: a minimum thread pool size of N allows up to N dependent
tasks to block on each other without resulting in a deadlock on monothread
systems, while limiting the number of concurrent running tasks.
Ring currently uses up to two dependent tasks with ThreadPool.

Change-Id: I66ec6ebb64ee4e1fb84af2db9aa465c62e08eadd
This commit is contained in:
Adrien Béraud
2016-10-23 18:29:44 -04:00
committed by Guillaume Roguez
parent 7adf9f4d1e
commit e0cf7a6682

View File

@ -32,7 +32,7 @@ struct ThreadPool::ThreadState
};
ThreadPool::ThreadPool()
: maxThreads_(std::thread::hardware_concurrency())
: maxThreads_(std::max<size_t>(std::thread::hardware_concurrency(), 4))
{
threads_.reserve(maxThreads_);
}