From b0082066596178f7b72d9963bffdec306a5b6250 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Fri, 17 Nov 2023 14:38:13 +0100 Subject: fix named event (#553) * fix named event timout and test, fix blocking queue --- src/zencore/workthreadpool.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/zencore/workthreadpool.cpp') diff --git a/src/zencore/workthreadpool.cpp b/src/zencore/workthreadpool.cpp index 3a4b1e6a1..bdb9de9dc 100644 --- a/src/zencore/workthreadpool.cpp +++ b/src/zencore/workthreadpool.cpp @@ -150,7 +150,10 @@ struct WorkerThreadPool::Impl for (std::thread& Thread : m_WorkerThreads) { - Thread.join(); + if (Thread.joinable()) + { + Thread.join(); + } } m_WorkerThreads.clear(); @@ -219,7 +222,16 @@ WorkerThreadPool::ScheduleWork(Ref Work) } else { - Work->Execute(); + try + { + Work->Execute(); + } + catch (std::exception& e) + { + Work->m_Exception = std::current_exception(); + + ZEN_WARN("Caught exception when executing worker synchronously: {}", e.what()); + } } } -- cgit v1.2.3 From edec4c2ef0de9df5f335152ed143d45f2f8e1c55 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Tue, 28 Nov 2023 16:39:30 -0500 Subject: close thread pool + parallel CasImpl::Initialize (#576) * close thread pool at destruction * parallell casimpl::initialize --- src/zencore/workthreadpool.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/zencore/workthreadpool.cpp') diff --git a/src/zencore/workthreadpool.cpp b/src/zencore/workthreadpool.cpp index bdb9de9dc..e6a6b5c54 100644 --- a/src/zencore/workthreadpool.cpp +++ b/src/zencore/workthreadpool.cpp @@ -74,6 +74,7 @@ struct WorkerThreadPool::Impl { WaitForThreadpoolWorkCallbacks(m_Work, /* CancelPendingCallbacks */ TRUE); CloseThreadpoolWork(m_Work); + CloseThreadpool(m_ThreadPool); } void ScheduleWork(Ref Work) -- cgit v1.2.3 From 68b3382ef7e0f7795b9a601aae73adc2f8ef9873 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Wed, 29 Nov 2023 09:14:57 -0500 Subject: global thread worker pools (#577) - Improvement: Use two global worker thread pools instead of ad-hoc creation of worker pools --- src/zencore/workthreadpool.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/zencore/workthreadpool.cpp') diff --git a/src/zencore/workthreadpool.cpp b/src/zencore/workthreadpool.cpp index e6a6b5c54..6ff6463dd 100644 --- a/src/zencore/workthreadpool.cpp +++ b/src/zencore/workthreadpool.cpp @@ -110,6 +110,7 @@ struct WorkerThreadPool::Impl m_WorkQueue.pop_front(); } + ZEN_TRACE_CPU_FLUSH("AsyncWork"); WorkFromQueue->Execute(); } }; @@ -178,6 +179,7 @@ WorkerThreadPool::Impl::WorkerThreadFunction(ThreadStartInfo Info) { try { + ZEN_TRACE_CPU_FLUSH("AsyncWork"); Work->Execute(); } catch (std::exception& e) @@ -225,6 +227,7 @@ WorkerThreadPool::ScheduleWork(Ref Work) { try { + ZEN_TRACE_CPU_FLUSH("SyncWork"); Work->Execute(); } catch (std::exception& e) -- cgit v1.2.3