From 849bca485541b710a71cb83ea0fc6b09f7c0d0a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 2 Oct 2018 10:42:10 +0200 Subject: [PATCH] Avoid starting an explicit event loop in worker threads. This reduces the overhead of task pool threads slightly and simplifies stack traces in case of errors. --- source/vibe/core/taskpool.d | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/source/vibe/core/taskpool.d b/source/vibe/core/taskpool.d index 642cb1f..736f770 100644 --- a/source/vibe/core/taskpool.d +++ b/source/vibe/core/taskpool.d @@ -253,14 +253,8 @@ private final class WorkerThread : Thread { try { if (m_pool.m_state.lock.term) return; logDebug("entering worker thread"); - runTask(&handleWorkerTasks); - logDebug("running event loop"); - if (!m_pool.m_state.lock.term) runEventLoop(); + handleWorkerTasks(); logDebug("Worker thread exit."); - } catch (Exception e) { - scope (failure) abort(); - logFatal("Worker thread terminated due to uncaught exception: %s", e.msg); - logDebug("Full error: %s", e.toString().sanitize()); } catch (Throwable th) { logFatal("Worker thread terminated due to uncaught error: %s", th.msg); logDebug("Full error: %s", th.toString().sanitize()); @@ -307,8 +301,6 @@ private final class WorkerThread : Thread { if (threads.length > 0 && !queue.empty) logWarn("Worker threads shut down with worker tasks still left in the queue."); } - - exitEventLoop(); } }