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
Durationtype to represent a span of time, typically used for system timeouts. - Join
Handle - An owned permission to join on a thread (block on its termination).
- Thread
- A handle to a thread.
- Thread
Id - 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
JoinHandlefor 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