logos.std.thread

Module std · package logos-std

Types

structJoinHandle

struct JoinHandle

Owned handle to a spawned OS thread; used to join or detach it exactly once.

Fields

joined: bool
tid: i64

Methods

fn detach(self: &mut JoinHandle) -> void

Detaches the thread: it runs to completion independently and can no longer be joined. No-op if the handle was already joined or detached.

fn id(self: &JoinHandle) -> i64

Returns the underlying pthread thread ID.

fn join(self: &mut JoinHandle) -> *mut u8

Waits for the thread to finish and returns the raw exit pointer from the thread function (whatever it returned, cast to *mut u8). Returns null if the handle was already joined or detached.

Functions

fncurrent_id

fn current_id() -> i64

Returns the calling thread’s pthread ID (opaque; comparable with ==).

fnthread_spawn

fn thread_spawn(start: *const u8, arg: *mut u8) -> JoinHandle

Spawns a new OS thread running start(arg). start must be a function pointer with signature fn(*mut u8) -> *mut u8 (cast from a concrete Logos fn using as *const u8); arg is passed through unchanged. On failure returns a JoinHandle with tid == -1, already marked joined.

fnyield_now

fn yield_now() -> void

Hints to the scheduler that the current thread is willing to yield to others.