medfall

A super great game engine
Log | Files | Refs

commit d96a5f1e45dd7e803ff5cd2f0020b85efa18089c
parent f9dc4664d67219665ab5abdfc914a4a8fee331c2
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sun Apr 23 01:35:50 +0300

Simplify workqueue_init a bit

Diffstat:
work_queue.cc | 16+---------------
1 file changed, 1 insertion(+), 15 deletions(-)
diff --git a/work_queue.cc b/work_queue.cc @@ -6,14 +6,12 @@ #include "array.h" #include "log.h" #include "work_queue.h" -#include "platform_atomic.h" #include "platform_semaphore.h" #include "platform_thread.h" struct ThreadInfo { u32 thread_id; WorkQueue * queue; - atomic_u32 * started_threads; }; static bool workqueue_step( u32 thread_id, WorkQueue * queue ) { @@ -41,8 +39,6 @@ static THREAD( workqueue_worker ) { WorkQueue * queue = info->queue; u32 thread_id = info->thread_id; - fetch_add_acqrel( info->started_threads, 1 ); - logger_thread_name( "worker %u", thread_id ); while( load_acquire( &queue->shutting_down ) == 0 ) { @@ -68,22 +64,12 @@ void workqueue_init( WorkQueue * queue, MemoryArena * arena, u32 num_threads ) { queue->arenas[ i ] = memarena_push_arena( arena, megabytes( 16 ) ); } - MEMARENA_SCOPED_CHECKPOINT( arena ); - ThreadInfo * infos = memarena_push_many( arena, ThreadInfo, num_threads ); - atomic_u32 started_threads; - store_release( &started_threads, 0 ); for( u32 i = 0; i < num_threads; i++ ) { - infos[ i ] = { i, queue, &started_threads }; + infos[ i ] = { i, queue }; thread_init( &queue->threads[ i ], workqueue_worker, &infos[ i ] ); } - - // wait until all threads have a local copy of ThreadInfo - // TODO: do this properly - while( load_acquire( &started_threads ) < num_threads ) { - continue; - } } void workqueue_enqueue( WorkQueue * queue, WorkQueueCallback * callback, const void * data ) {