mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Fix pool running
This commit is contained in:
+4
-2
@@ -29,6 +29,9 @@ gb_internal void thread_pool_init(ThreadPool *pool, gbAllocator const &a, isize
|
|||||||
pool->allocator = a;
|
pool->allocator = a;
|
||||||
slice_init(&pool->threads, a, thread_count + 1);
|
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
|
// setup the main thread
|
||||||
thread_init(pool, &pool->threads[0], 0);
|
thread_init(pool, &pool->threads[0], 0);
|
||||||
current_thread = &pool->threads[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 *t = &pool->threads[i];
|
||||||
thread_init_and_start(pool, t, i);
|
thread_init_and_start(pool, t, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
pool->running.store(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gb_internal void thread_pool_destroy(ThreadPool *pool) {
|
gb_internal void thread_pool_destroy(ThreadPool *pool) {
|
||||||
@@ -138,6 +139,7 @@ gb_internal THREAD_PROC(thread_pool_thread_proc) {
|
|||||||
WorkerTask task;
|
WorkerTask task;
|
||||||
current_thread = thread;
|
current_thread = thread;
|
||||||
ThreadPool *pool = current_thread->pool;
|
ThreadPool *pool = current_thread->pool;
|
||||||
|
// debugf("worker id: %td\n", current_thread->idx);
|
||||||
|
|
||||||
while (pool->running.load()) {
|
while (pool->running.load()) {
|
||||||
// If we've got tasks to process, work through them
|
// If we've got tasks to process, work through them
|
||||||
|
|||||||
Reference in New Issue
Block a user