Skip to main content

Module thread

Module thread 

Source
Expand description

Threading utilities

Windjammer’s thread module provides ergonomic thread spawning and management with simplified error handling.

Structs§

Builder
Thread factory, which can be used in order to configure the properties of a new thread.
Duration
A Duration type to represent a span of time, typically used for system timeouts.
JoinHandle
An owned permission to join on a thread (block on its termination).
Thread
A handle to a thread.
ThreadId
A unique identifier for a running thread.

Functions§

available_parallelism
Get available parallelism (number of logical cores)
current
Gets a handle to the thread that invokes it.
current_id
Get the current thread ID
current_name
Get the current thread name
current_thread
Get the current thread
is_panicking
Check if the current thread is panicking
join
Join a thread and unwrap the result
panicking
Determines whether the current thread is panicking.
park
Blocks unless or until the current thread’s token is made available.
park_thread
Park the current thread
park_thread_timeout
Park the current thread with timeout
park_timeout
Blocks unless or until the current thread’s token is made available or the specified duration has been reached (may wake spuriously).
scope
Scope-based thread spawning (safe scoped threads)
sleep
Puts the current thread to sleep for at least the specified amount of time.
sleep_micros
Sleep for a number of microseconds
sleep_millis
Sleep for a number of milliseconds
sleep_seconds
Sleep for a number of seconds
spawn
Spawns a new thread, returning a JoinHandle for it.
spawn_thread
Spawn a new thread with a closure
try_join
Try to join a thread
yield_now
Cooperatively gives up a timeslice to the OS scheduler.
yield_thread
Yield the current thread