Import with #import "std/thread_linux".

ThreadProcedure :: #type (argument: *void)
PosixThreadEntry :: #type (argument: *void) -> *void
ThreadJoinable :: (thread: *Thread) -> bool
ThreadNotification :: struct { procedure: ThreadProcedure; argument: *void; }
Thread :: struct { handle: usize; lock: [8]u64; procedure: ThreadProcedure; argument: *void; notification: ThreadNotification; running: bool; finished: bool; returned: bool; }
ThreadLock :: (thread: *Thread) -> *void
ThreadRun :: (argument: *void) -> *void
ThreadStart :: (thread: *Thread, procedure: ThreadProcedure, argument: *void, notification: ThreadNotification) -> bool

Starts `procedure(argument)` on a new thread. Returns false when the record is still running something or no thread could be started. `notification.procedure(notification.argument)` runs once after completion is published, so an event loop can wake without polling. It must not join or restart this Thread. Both arguments must live until the owner joins it.

ThreadRunning :: (thread: *Thread) -> bool

Whether the record is running a procedure that has not been reported finished yet.

ThreadFinished :: (thread: *Thread) -> bool

Whether the procedure started on `thread` has finished. Never waits; the first time it reports true the thread is joined and the record is free.

ThreadWait :: (thread: *Thread)

Waits until the procedure started on `thread` has finished.

Source ↗ · All modules