mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-15 07:43:13 +00:00
Merge pull request #5900 from laytan/another-thread-cancel-try
removes the darwin specific paths from thread_unix
This commit is contained in:
@@ -22,11 +22,6 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread {
|
||||
__unix_thread_entry_proc :: proc "c" (t: rawptr) -> rawptr {
|
||||
t := (^Thread)(t)
|
||||
|
||||
// We need to give the thread a moment to start up before we enable cancellation.
|
||||
// NOTE(laytan): setting to .DISABLE on darwin, with .ENABLE pthread_cancel would deadlock
|
||||
// most of the time, don't ask me why.
|
||||
can_set_thread_cancel_state := posix.pthread_setcancelstate(.DISABLE when ODIN_OS == .Darwin else .ENABLE, nil) == nil
|
||||
|
||||
t.id = sync.current_thread_id()
|
||||
|
||||
for (.Started not_in sync.atomic_load(&t.flags)) {
|
||||
@@ -34,16 +29,14 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread {
|
||||
}
|
||||
|
||||
// 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
|
||||
// basically always make it deadlock.
|
||||
if ODIN_OS != .Darwin && can_set_thread_cancel_state {
|
||||
err := posix.pthread_setcancelstate(.ENABLE, nil)
|
||||
assert_contextless(err == nil)
|
||||
err := posix.pthread_setcancelstate(.ENABLE, nil)
|
||||
assert_contextless(err == nil)
|
||||
|
||||
err = posix.pthread_setcanceltype(.ASYNCHRONOUS, nil)
|
||||
assert_contextless(err == nil)
|
||||
}
|
||||
// NOTE(laytan): .ASYNCHRONOUS should make `pthread_cancel` cancel immediately
|
||||
// instead of waiting for a cancellation point.
|
||||
// This does not seem to work on at least Darwin and NetBSD though.
|
||||
err = posix.pthread_setcanceltype(.ASYNCHRONOUS, nil)
|
||||
assert_contextless(err == nil)
|
||||
|
||||
{
|
||||
init_context := t.init_context
|
||||
|
||||
Reference in New Issue
Block a user