mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 14:18:47 +00:00
Fix early join after start.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user