Add timed thread join

This commit is contained in:
2026-07-17 18:12:21 +10:00
parent e1991685ef
commit b7ecf2439a
9 changed files with 274 additions and 177 deletions
+10 -3
View File
@@ -1,4 +1,4 @@
// Generated by the DN single header generator 2026-07-16 23:31:53
// Generated by the DN single header generator 2026-07-17 17:54:42
#if !defined(DN_H)
#define DN_H
@@ -4442,6 +4442,9 @@ struct DN_OSThread
DN_OSThreadFunc *func;
DN_OSSemaphore thread_exec_wait_for_thread_id_sem;
DN_OSSemaphore caller_wait_for_thread_init_to_finish_sem;
#if !defined(DN_PLATFORM_WIN32)
DN_OSSemaphore join_done_sem;
#endif
DN_TCInitArgs tc_init_args;
};
@@ -6701,9 +6704,13 @@ DN_API void DN_OS_ConditionVariableBroadcast (D
//
// For the general use-case if you wish to use lanes then prefer the `DN_OS_ThreadLane` APIs
// below which create the threads with the lane information setup accordingly.
// DN_OS_ThreadJoin
// Returns true if the thread joined successfully or it is already joined. False if timed out
// waiting for the thread to join.
DN_API bool DN_OS_ThreadInitLane (DN_OSThread *thread, DN_OSThreadFunc *func, DN_OSThreadLane *lane, DN_OSThreadInitArgs init_args, void *user_context);
DN_API bool DN_OS_ThreadInit (DN_OSThread *thread, DN_OSThreadFunc *func, DN_OSThreadInitArgs init_args, void *user_context);
DN_API bool DN_OS_ThreadJoin (DN_OSThread *thread, DN_TCDeinitArenas deinit_arenas);
DN_API bool DN_OS_ThreadJoin (DN_OSThread *thread, DN_U32 timeout_ms, DN_TCDeinitArenas deinit_arenas);
DN_API DN_U32 DN_OS_ThreadID ();
DN_API DN_OSThreadInitArgs DN_OS_ThreadInitArgsDefault ();
DN_API void DN_OS_ThreadSetNameFmt (char const *fmt, ...);
@@ -6777,7 +6784,7 @@ DN_API DN_V2USize DN_OS_ThreadLaneRange (D
DN_API DN_OSThreadLaneway DN_OS_ThreadLanewayFromArgs (DN_OSThread* threads, DN_USize threads_count, DN_UPtr* shared_mem);
DN_API DN_OSThreadLaneway DN_OS_ThreadLanewayFromArena (DN_USize threads_count, DN_Arena* arena);
DN_API void DN_OS_ThreadLanewayDispatch (DN_OSThreadLaneway *laneway, DN_OSThreadFunc *entry_point, DN_OSThreadInitArgs init_args, void *user_context);
DN_API void DN_OS_ThreadLanewayJoin (DN_OSThreadLaneway *laneway, DN_TCDeinitArenas deinit_arenas);
DN_API void DN_OS_ThreadLanewayJoin (DN_OSThreadLaneway *laneway, DN_U32 timeout_ms, DN_TCDeinitArenas deinit_arenas);
DN_API DN_OSThreadLane* DN_OS_TCThreadLane ();
DN_API void DN_OS_TCThreadLaneSync (void **ptr_to_share);