From 471770154092610f71241c4a34bb6b9303d29389 Mon Sep 17 00:00:00 2001 From: Nikita Smith Date: Thu, 18 Sep 2025 00:42:56 -0700 Subject: [PATCH] update threading API --- src/linker/lnk.c | 9 ++++++--- src/linker/thread_pool/thread_pool.c | 14 +++++++------- src/linker/thread_pool/thread_pool.h | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/linker/lnk.c b/src/linker/lnk.c index bb7491c5..1ba486ba 100644 --- a/src/linker/lnk.c +++ b/src/linker/lnk.c @@ -132,7 +132,10 @@ lnk_config_from_argcv(Arena *arena, int argc, char **argv) { Temp scratch = scratch_begin(&arena, 1); - String8List raw_cmd_line = os_string_list_from_argcv(arena, argc, argv); + String8List raw_cmd_line = {0}; + for EachIndex(i, argc) { + str8_list_push(arena, &raw_cmd_line, str8_cstring(argv[i])); + } // remove exe name first argument str8_list_pop_front(&raw_cmd_line); @@ -4995,7 +4998,7 @@ lnk_run(TP_Context *tp, TP_Arena *arena, LNK_Config *config) image_write_ctx->path = config->image_name; image_write_ctx->temp_path = config->temp_image_name; image_write_ctx->data = image_ctx.image_data; - OS_Handle image_write_thread = os_thread_launch(lnk_write_thread, image_write_ctx, 0); + Thread image_write_thread = thread_launch(lnk_write_thread, image_write_ctx); // // RAD Map @@ -5098,7 +5101,7 @@ lnk_run(TP_Context *tp, TP_Arena *arena, LNK_Config *config) } // wait for the thread to finish writing image to disk - os_thread_join(image_write_thread, -1); + thread_join(image_write_thread, -1); // // Timers diff --git a/src/linker/thread_pool/thread_pool.c b/src/linker/thread_pool/thread_pool.c index d4cbec81..da2f7814 100644 --- a/src/linker/thread_pool/thread_pool.c +++ b/src/linker/thread_pool/thread_pool.c @@ -99,7 +99,7 @@ tp_alloc(Arena *arena, U32 worker_count, U32 max_worker_count, String8 name) // launch worker threads for (U64 i = 1; i < worker_count; i += 1) { TP_Worker *worker = &pool->worker_arr[i]; - worker->handle = os_thread_launch(worker_entry, worker, 0); + worker->handle = thread_launch(worker_entry, worker); } ProfEnd(); @@ -114,20 +114,20 @@ tp_release(TP_Context *pool) B32 is_shared = pool->exec_semaphore.u64[0] != 0; if (is_shared) { for (U64 i = 0; i < pool->worker_count; ++i) { - os_semaphore_drop(pool->exec_semaphore); + semaphore_drop(pool->exec_semaphore); } } for (U64 i = 0; i < pool->worker_count; ++i) { - os_semaphore_drop(pool->task_semaphore); + semaphore_drop(pool->task_semaphore); } for (U64 i = 1; i < pool->worker_count; i += 1) { - os_thread_detach(pool->worker_arr[i].handle); + thread_detach(pool->worker_arr[i].handle); } if (is_shared) { - os_semaphore_release(pool->exec_semaphore); + semaphore_release(pool->exec_semaphore); } - os_semaphore_release(pool->task_semaphore); - os_semaphore_release(pool->main_semaphore); + semaphore_release(pool->task_semaphore); + semaphore_release(pool->main_semaphore); MemoryZeroStruct(pool); } diff --git a/src/linker/thread_pool/thread_pool.h b/src/linker/thread_pool/thread_pool.h index c7e534df..abae8606 100644 --- a/src/linker/thread_pool/thread_pool.h +++ b/src/linker/thread_pool/thread_pool.h @@ -22,7 +22,7 @@ typedef struct TP_Worker { U64 id; struct TP_Context *pool; - OS_Handle handle; + Thread handle; } TP_Worker; typedef struct TP_Context