Module thread

thread

OS thread creation and management with per-thread IO event loops.

Types

Thread struct
Thread

OS thread handle. Each spawned thread gets its own IO event loop.

Fields

NameTypeDescription
handle__yo_thread_t
impl(Thread, ...)
spawn : (Thread) fn(cb : Impl(Fn(using(io : IO)) -> unit, Send)) -> Thread

Spawn a new OS thread running the given closure. The closure receives its own per-thread IO event loop.

Parameters

NameTypeNotes
cbImpl(Fn(using(io : IO)) -> unit, Send)

Returns: Thread

join : (Thread) fn(self : *(Thread)) -> unit

Block the current thread until this thread completes.

Parameters

NameTypeNotes
self*(Thread)

Returns: unit

Functions

fn() -> usize

Get the number of hardware threads (CPU cores) available.

Returns: usize

get_thread_id function
fn() -> usize

Get the current OS thread ID.

Returns: usize

get_cpu_id function
fn() -> i32

Get the current CPU core ID.

Returns: i32