From 3a6a5855cf36967c6bde31292669bfaf832c6f0b Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Mon, 30 Oct 2023 09:32:54 +0100 Subject: New GC implementation (#459) - Feature: New garbage collection implementation, still in evaluation mode. Enabled by `--gc-v2` command line option --- src/zencore/workthreadpool.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/zencore/workthreadpool.cpp') diff --git a/src/zencore/workthreadpool.cpp b/src/zencore/workthreadpool.cpp index cc21e717a..3a4b1e6a1 100644 --- a/src/zencore/workthreadpool.cpp +++ b/src/zencore/workthreadpool.cpp @@ -199,7 +199,10 @@ WorkerThreadPool::WorkerThreadPool(int InThreadCount) : WorkerThreadPool(InThrea WorkerThreadPool::WorkerThreadPool(int InThreadCount, std::string_view WorkerThreadBaseName) { - m_Impl = std::make_unique(InThreadCount, WorkerThreadBaseName); + if (InThreadCount > 0) + { + m_Impl = std::make_unique(InThreadCount, WorkerThreadBaseName); + } } WorkerThreadPool::~WorkerThreadPool() @@ -210,7 +213,14 @@ WorkerThreadPool::~WorkerThreadPool() void WorkerThreadPool::ScheduleWork(Ref Work) { - m_Impl->ScheduleWork(std::move(Work)); + if (m_Impl) + { + m_Impl->ScheduleWork(std::move(Work)); + } + else + { + Work->Execute(); + } } void @@ -222,7 +232,11 @@ WorkerThreadPool::ScheduleWork(std::function&& Work) [[nodiscard]] size_t WorkerThreadPool::PendingWorkItemCount() const { - return m_Impl->PendingWorkItemCount(); + if (m_Impl) + { + return m_Impl->PendingWorkItemCount(); + } + return 0; } ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3