From eb18b2892862c650b7ab7997e3f3c3d5b9d2a403 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 5 Sep 2023 06:02:58 -0500 Subject: [PATCH] workPool: improvements --- src/engine/workPool.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/engine/workPool.cpp b/src/engine/workPool.cpp index d7c1f6b2..a62f4ff7 100644 --- a/src/engine/workPool.cpp +++ b/src/engine/workPool.cpp @@ -64,10 +64,8 @@ bool DivWorkThread::assign(const std::function& what, void* arg) { } tasks.push(DivPendingTask(what,arg)); parent->busyCount++; - parent->notify.notify_one(); isBusy=true; lock.unlock(); - notify.notify_one(); return true; } @@ -93,21 +91,19 @@ void DivWorkThread::init(DivWorkPool* p) { } void DivWorkPool::push(const std::function& what, void* arg) { - //logV("submitting work"); // if no work threads, just execute if (!threaded) { what(arg); return; } - if (pos>=count) pos=0; - for (unsigned int tryCount=0; tryCount=count) pos=0; if (workThreads[pos++].assign(what,arg)) return; } // all threads are busy - logV("all busy"); + logW("DivWorkPool: all work threads busy!"); what(arg); } @@ -122,8 +118,17 @@ bool DivWorkPool::busy() { void DivWorkPool::wait() { if (!threaded) return; std::unique_lock unique(selfLock); + + // start running + for (unsigned int i=0; i