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.

Fields

impl: Impl,

Namespaces

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 getHandle(self: Thread) Handle

Returns the handle of this thread

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 setName(self: Thread, name: []const u8) SetNameError!void

No documentation provided.

fn spawn(config: SpawnConfig, comptime function: anytype, args: anytype) SpawnError!Thread

Spawns a new thread which executes function using args and returns a handle …

Spawns a new thread which executes function using args and returns a handle to the spawned thread. config can be used as hints to the platform for now to spawn and execute the function. The caller must eventually either call join() to wait for the thread to finish and free its resources or call detach() to excuse the caller from calling join() and have the thread clean up its resources on completion.

fn yield() YieldError!void

Yields the current thread potentially allowing other threads to run.

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