aboutsummaryrefslogtreecommitdiff
path: root/src/thread_pool.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-01-02 18:04:16 +0000
committergingerBill <bill@gingerbill.org>2023-01-02 18:04:16 +0000
commit1568971732bd04a7f68a52277c0b2ab0cb5009c2 (patch)
tree634e042c9b4caaab74090fdb7108b5c24171f34e /src/thread_pool.cpp
parent0e040be9411328d2e82556b7a37fa1cf90b666bd (diff)
Fix pool running
Diffstat (limited to 'src/thread_pool.cpp')
-rw-r--r--src/thread_pool.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/thread_pool.cpp b/src/thread_pool.cpp
index f1f19b275..a429e47ff 100644
--- a/src/thread_pool.cpp
+++ b/src/thread_pool.cpp
@@ -29,6 +29,9 @@ gb_internal void thread_pool_init(ThreadPool *pool, gbAllocator const &a, isize
pool->allocator = a;
slice_init(&pool->threads, a, thread_count + 1);
+ // NOTE: this needs to be initialized before any thread starts
+ pool->running.store(true);
+
// setup the main thread
thread_init(pool, &pool->threads[0], 0);
current_thread = &pool->threads[0];
@@ -37,8 +40,6 @@ gb_internal void thread_pool_init(ThreadPool *pool, gbAllocator const &a, isize
Thread *t = &pool->threads[i];
thread_init_and_start(pool, t, i);
}
-
- pool->running.store(true);
}
gb_internal void thread_pool_destroy(ThreadPool *pool) {
@@ -138,6 +139,7 @@ gb_internal THREAD_PROC(thread_pool_thread_proc) {
WorkerTask task;
current_thread = thread;
ThreadPool *pool = current_thread->pool;
+ // debugf("worker id: %td\n", current_thread->idx);
while (pool->running.load()) {
// If we've got tasks to process, work through them