diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2025-06-21 11:54:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-21 11:54:46 +0200 |
| commit | edb1f8a76dfb380d862fb2d2d1239a398fc87fcd (patch) | |
| tree | cba4f52771815f3308314fcfbab601bf150cd928 /core/thread/thread_unix.odin | |
| parent | 8dc374a6ae43d773eba78a66d850a3733d500988 (diff) | |
| parent | 1903d7211ee42286cb45aa77a7c97e3bb131e4d5 (diff) | |
Merge pull request #5383 from Kelimion/thread-fix
Fix early join after start.
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) { |