This struct represents a kernel thread, and acts as a namespace for concurrency primitives that operate on kernel threads. For concurrency primitives that support both evented I/O and async I/O, see the respective names in the top level std namespace.
Functions
fn detach(self: Thread) void
Release the obligation of the caller to call
join()
and have the thread clean …Release the obligation of the caller to call
join()
and have the thread clean up its own resources on completion. Once called, this consumes the Thread object and invoking any other functions on it is considered undefined behavior.fn getCpuCount() CpuCountError!usize
Returns the platforms view on the number of logical CPU cores available.
fn getCurrentId() Id
Returns the platform ID of the callers thread. Attempts to use thread locals an…
Returns the platform ID of the callers thread. Attempts to use thread locals and avoid syscalls when possible.
fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]const u8
No documentation provided.
fn join(self: Thread) void
Waits for the thread to complete, then deallocates any resources created on `spa…
Waits for the thread to complete, then deallocates any resources created on
spawn()
. Once called, this consumes the Thread object and invoking any other functions on it is considered undefined behavior.fn spawn(config: SpawnConfig, comptime function: anytype, args: anytype) SpawnError!Thread
Spawns a new thread which executes
function
usingargs
and returns a handle …Spawns a new thread which executes
function
usingargs
and returns a handle to the spawned thread.config
can be used as hints to the platform for now to spawn and execute thefunction
. The caller must eventually either calljoin()
to wait for the thread to finish and free its resources or calldetach()
to excuse the caller from callingjoin()
and have the thread clean up its resources on completion.
Values
GetNameError | type | |
Handle | undefined | Represents a kernel thread handle. May be an integer or a pointer depending on … |
Id | type | Represents an ID per thread guaranteed to be unique only within a process. |
SetNameError | type | |
max_name_len | type | |
use_pthreads | bool |