diff options
Diffstat (limited to 'src/zencore/workthreadpool.cpp')
| -rw-r--r-- | src/zencore/workthreadpool.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
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<Impl>(InThreadCount, WorkerThreadBaseName); + if (InThreadCount > 0) + { + m_Impl = std::make_unique<Impl>(InThreadCount, WorkerThreadBaseName); + } } WorkerThreadPool::~WorkerThreadPool() @@ -210,7 +213,14 @@ WorkerThreadPool::~WorkerThreadPool() void WorkerThreadPool::ScheduleWork(Ref<IWork> 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<void()>&& Work) [[nodiscard]] size_t WorkerThreadPool::PendingWorkItemCount() const { - return m_Impl->PendingWorkItemCount(); + if (m_Impl) + { + return m_Impl->PendingWorkItemCount(); + } + return 0; } ////////////////////////////////////////////////////////////////////////// |