diff options
| author | gingerBill <bill@gingerbill.org> | 2021-07-10 21:50:19 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-07-10 21:50:19 +0100 |
| commit | 8a6b743d2a310f6acd9e4d8a3284fdd7ba94fe50 (patch) | |
| tree | 03d7972dbc3a747778a9f62c0f2de8d38615bb64 /src | |
| parent | ed8a6f872dbcd8b195940dec40a0d86d59f11eaa (diff) | |
Simplify `thread_pool_wait_to_process`
Diffstat (limited to 'src')
| -rw-r--r-- | src/thread_pool.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/thread_pool.cpp b/src/thread_pool.cpp index 9e178b833..fdd86a3e0 100644 --- a/src/thread_pool.cpp +++ b/src/thread_pool.cpp @@ -124,6 +124,13 @@ void thread_pool_do_work(ThreadPool *pool, WorkerTask *task) { } void thread_pool_wait_to_process(ThreadPool *pool) { + if (pool->thread_count == 0) { + WorkerTask task = {}; + while (thread_pool_try_and_pop_task(pool, &task)) { + thread_pool_do_work(pool, &task); + } + return; + } while (pool->tasks.count.load(std::memory_order_relaxed) > 0 || gb_atomic32_load(&pool->processing_work_count) != 0) { WorkerTask task = {}; if (thread_pool_try_and_pop_task(pool, &task)) { |