From 8eff0016552db641d543e37b6c4fff1fe8cdb5c9 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sat, 6 Oct 2018 11:07:11 +0200 Subject: [PATCH] Initialize queues properly --- src/thread/parallel.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/thread/parallel.cpp b/src/thread/parallel.cpp index 5e16961..83ef647 100644 --- a/src/thread/parallel.cpp +++ b/src/thread/parallel.cpp @@ -64,6 +64,7 @@ namespace fc { { public: pool_impl( const uint16_t num_threads ) + : idle_threads( 2 * num_threads ), waiting_tasks( 200 ) { notifiers.resize( num_threads ); threads.reserve( num_threads ); @@ -99,7 +100,8 @@ namespace fc { threads[ini->id]->async_task( task, priority() ); return; } - waiting_tasks.push( task ); + while( !waiting_tasks.push( task ) ) + elog( "Worker pool internal error" ); } task_base* enqueue_idle_thread( idle_notifier_impl* ini ) @@ -110,7 +112,8 @@ namespace fc { fc::unique_lock lock(pool_lock); if( waiting_tasks.pop( task ) ) return task; - idle_threads.push( ini ); + while( !idle_threads.push( ini ) ) + elog( "Worker pool internal error" ); return 0; } private: