From 274d2300b26d5c97481219fd8a5b8893613c7e7b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Fri, 3 Feb 2017 14:37:22 -0500 Subject: [PATCH] pthreads: intro `ThreadPool::join_all` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/pthreads/threadpool.nit | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/pthreads/threadpool.nit b/lib/pthreads/threadpool.nit index cbb6594..927cdbf 100644 --- a/lib/pthreads/threadpool.nit +++ b/lib/pthreads/threadpool.nit @@ -42,6 +42,15 @@ class ThreadPool queue.push(task) cond.signal end + + # Join all threads, waiting for all tasks to be completed + fun join_all do + # Wait + for t in threads do t.join + + # Reset + threads.clear + end end # A Thread running in a threadpool -- 1.7.9.5