diff options
| author | Dan Engelbrecht <[email protected]> | 2023-10-30 09:32:54 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-30 09:32:54 +0100 |
| commit | 3a6a5855cf36967c6bde31292669bfaf832c6f0b (patch) | |
| tree | 593e7c21e6840e7ad312207fddc63e1934e19d85 /src/zencore/workthreadpool.cpp | |
| parent | set up arch properly when running tests (mac) (#505) (diff) | |
| download | zen-3a6a5855cf36967c6bde31292669bfaf832c6f0b.tar.xz zen-3a6a5855cf36967c6bde31292669bfaf832c6f0b.zip | |
New GC implementation (#459)
- Feature: New garbage collection implementation, still in evaluation mode. Enabled by `--gc-v2` command line option
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; } ////////////////////////////////////////////////////////////////////////// |