detach
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.
Function parameters
Parameters
Type definitions in this namespace
Types
- SpawnConfig
- Configuration options for hints on how to spawn threads.
Spurious wakeups are possible and no precision of timing is guaranteed.
Functions
- sleep
- Spurious wakeups are possible and no precision of timing is guaranteed.
- getName
- On Windows, the result is encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).
- getCurrentId
- Returns the platform ID of the callers thread.
- getCpuCount
- Returns the platforms view on the number of logical CPU cores available.
- spawn
- Spawns a new thread which executes `function` using `args` and returns a handle to the spawned thread.
- getHandle
- Returns the handle of this thread
- detach
- Release the obligation of the caller to call `join()` and have the thread clean up its own resources on completion.
- join
- Waits for the thread to complete, then deallocates any resources created on `spawn()`.
- yield
- Yields the current thread potentially allowing other threads to run.
Error sets in this namespace
Error Sets
= native_os != .windows and native_os != .wasi and builtin.link_libc
Values
- use_pthreads
- = native_os != .windows and native_os != .wasi and builtin.link_libc
- max_name_len
- = switch (native_os) { .linux => 15, .windows => 31, .macos, .ios, .watchos, .tvos, .visionos => 63, .netbsd => 31, .freebsd => 15, .openbsd => 23, .dragonfly => 1023, .solaris, .illumos => 31, // https://github.com/SerenityOS/serenity/blob/6b4c300353da49d3508b5442cf61da70bd04d757/Kernel/Tasks/Thread.h#L102 .serenity => 63, else => 0, }
- Handle
- Represents a kernel thread handle.
Source
Implementation
pub fn detach(self: Thread) void {
return self.impl.detach();
}