diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2022-05-11 16:17:35 +0200 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2022-05-11 16:17:35 +0200 |
| commit | f4ad4c7aa6f9137dd10c9d201e80f072181d2f93 (patch) | |
| tree | f3e69e9d927ec2981cb3e913f8f989a1130162d3 /core/thread | |
| parent | 8fb718245a76cc9daa45122e6e6990f558b14de7 (diff) | |
Disable thread.terminate on Darwin for now.
Diffstat (limited to 'core/thread')
| -rw-r--r-- | core/thread/thread_unix.odin | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/core/thread/thread_unix.odin b/core/thread/thread_unix.odin index 1a2b30197..8c7058f17 100644 --- a/core/thread/thread_unix.odin +++ b/core/thread/thread_unix.odin @@ -31,8 +31,10 @@ _create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^ __linux_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. - can_set_thread_cancel_state := unix.pthread_setcancelstate(unix.PTHREAD_CANCEL_DISABLE, nil) == 0 + when ODIN_OS != .Darwin { + // We need to give the thread a moment to start up before we enable cancellation. + can_set_thread_cancel_state := unix.pthread_setcancelstate(unix.PTHREAD_CANCEL_DISABLE, nil) == 0 + } context = runtime.default_context() @@ -47,10 +49,12 @@ _create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^ init_context := t.init_context context = init_context.? or_else runtime.default_context() - // Enable thread's cancelability. - if can_set_thread_cancel_state { - unix.pthread_setcanceltype (unix.PTHREAD_CANCEL_ASYNCHRONOUS, nil) - unix.pthread_setcancelstate(unix.PTHREAD_CANCEL_DISABLE, nil) + when ODIN_OS != .Darwin { + // Enable thread's cancelability. + if can_set_thread_cancel_state { + unix.pthread_setcanceltype (unix.PTHREAD_CANCEL_ASYNCHRONOUS, nil) + unix.pthread_setcancelstate(unix.PTHREAD_CANCEL_DISABLE, nil) + } } t.procedure(t) @@ -150,7 +154,10 @@ _destroy :: proc(t: ^Thread) { } _terminate :: proc(t: ^Thread, exit_code: int) { - unix.pthread_cancel(t.unix_thread) + // `pthread_cancel` is unreliable on Darwin for unknown reasons. + when ODIN_OS != .Darwin { + unix.pthread_cancel(t.unix_thread) + } } _yield :: proc() { |