multi_threaded->type_node = (AstType *) &basic_type_bool;
symbol_builtin_introduce(p->scope, "Multi_Threading_Enabled", (AstNode *) multi_threaded);
- AstNumLit* wait_notify_available = make_int_literal(a, context.options->use_multi_threading && context.options->runtime == Runtime_Js);
- wait_notify_available->type_node = (AstType *) &basic_type_bool;
- symbol_builtin_introduce(p->scope, "Wait_Notify_Available", (AstNode *) wait_notify_available);
-
AstNumLit* debug_mode = make_int_literal(a, context.options->debug_info_enabled);
debug_mode->type_node = (AstType *) &basic_type_bool;
symbol_builtin_introduce(p->scope, "Debug_Mode_Enabled", (AstNode *) debug_mode);
}
// __atomic_wait is only valid for i32 and i64
-#if runtime.Wait_Notify_Available {
- __atomic_wait :: (addr: &$T, value: T, timeout: i64 = -1) -> i32 #intrinsic ---
- __atomic_notify :: (addr: rawptr, maximum: i32 = 1) -> i32 #intrinsic ---
-}
+__atomic_wait :: (addr: &$T, value: T, timeout: i64 = -1) -> i32 #intrinsic ---
+__atomic_notify :: (addr: rawptr, maximum: i32 = 1) -> i32 #intrinsic ---
__atomic_fence :: () -> void #intrinsic ---
use runtime
use core
-#if runtime.Wait_Notify_Available {
- use core.intrinsics.atomics {__atomic_wait, __atomic_notify}
-}
-
#doc """
A semaphore represents a counter that can only be incremented
and decremented by one thread at a time. "Waiting" on a semaphore
"""
join :: (t: &Thread) {
while t.alive {
- #if runtime.Wait_Notify_Available {
- __atomic_wait(&t.id, t.id);
+ #if runtime.platform.Supports_Futexes {
+ runtime.platform.__futex_wait(&t.id, t.id, -1);
} else {
// To not completely kill the CPU.
runtime.platform.__sleep(1);
thread := thread_map->get(id)?;
if thread != null {
thread.alive = false;
- #if runtime.Wait_Notify_Available {
- __atomic_notify(&thread.id);
+ #if runtime.platform.Supports_Futexes {
+ runtime.platform.__futex_wake(&thread.id, 1);
}
thread_map->delete(id);