diff options
Diffstat (limited to 'core/thread/thread_unix.odin')
| -rw-r--r-- | core/thread/thread_unix.odin | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/core/thread/thread_unix.odin b/core/thread/thread_unix.odin index 7be5103ae..1431442a9 100644 --- a/core/thread/thread_unix.odin +++ b/core/thread/thread_unix.odin @@ -29,14 +29,10 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread { t.id = sync.current_thread_id() - if .Started not_in sync.atomic_load(&t.flags) { + for (.Started not_in sync.atomic_load(&t.flags)) { sync.wait(&t.start_ok) } - if .Joined in sync.atomic_load(&t.flags) { - return nil - } - // Enable thread's cancelability. // NOTE(laytan): Darwin does not correctly/fully support all of this, not doing this does // actually make pthread_cancel work in the capacity of my tests, while executing this would @@ -148,10 +144,13 @@ _join :: proc(t: ^Thread) { // Prevent non-started threads from blocking main thread with initial wait // condition. - if .Started not_in sync.atomic_load(&t.flags) { + for (.Started not_in sync.atomic_load(&t.flags)) { _start(t) } + posix.pthread_join(t.unix_thread, nil) + + t.flags += {.Joined} } _join_multiple :: proc(threads: ..^Thread) { |