mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Disable thread.terminate on Darwin for now.
This commit is contained in:
@@ -31,8 +31,10 @@ _create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^
|
|||||||
__linux_thread_entry_proc :: proc "c" (t: rawptr) -> rawptr {
|
__linux_thread_entry_proc :: proc "c" (t: rawptr) -> rawptr {
|
||||||
t := (^Thread)(t)
|
t := (^Thread)(t)
|
||||||
|
|
||||||
// We need to give the thread a moment to start up before we enable cancellation.
|
when ODIN_OS != .Darwin {
|
||||||
can_set_thread_cancel_state := unix.pthread_setcancelstate(unix.PTHREAD_CANCEL_DISABLE, nil) == 0
|
// 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()
|
context = runtime.default_context()
|
||||||
|
|
||||||
@@ -47,10 +49,12 @@ _create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^
|
|||||||
init_context := t.init_context
|
init_context := t.init_context
|
||||||
context = init_context.? or_else runtime.default_context()
|
context = init_context.? or_else runtime.default_context()
|
||||||
|
|
||||||
// Enable thread's cancelability.
|
when ODIN_OS != .Darwin {
|
||||||
if can_set_thread_cancel_state {
|
// Enable thread's cancelability.
|
||||||
unix.pthread_setcanceltype (unix.PTHREAD_CANCEL_ASYNCHRONOUS, nil)
|
if can_set_thread_cancel_state {
|
||||||
unix.pthread_setcancelstate(unix.PTHREAD_CANCEL_DISABLE, nil)
|
unix.pthread_setcanceltype (unix.PTHREAD_CANCEL_ASYNCHRONOUS, nil)
|
||||||
|
unix.pthread_setcancelstate(unix.PTHREAD_CANCEL_DISABLE, nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t.procedure(t)
|
t.procedure(t)
|
||||||
@@ -150,7 +154,10 @@ _destroy :: proc(t: ^Thread) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_terminate :: proc(t: ^Thread, exit_code: int) {
|
_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() {
|
_yield :: proc() {
|
||||||
|
|||||||
Reference in New Issue
Block a user