From e0cf7a66821f4ea484ae90df5c130addeb8f7844 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Sun, 23 Oct 2016 18:29:44 -0400
Subject: [PATCH] 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
---
 src/thread_pool.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/thread_pool.cpp b/src/thread_pool.cpp
index d913ce78d5..1b72769036 100644
--- a/src/thread_pool.cpp
+++ b/src/thread_pool.cpp
@@ -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_);
 }
-- 
GitLab