Trait twizzler_runtime_api::ThreadRuntime
source · pub trait ThreadRuntime {
// Required methods
fn available_parallelism(&self) -> NonZeroUsize;
fn futex_wait(
&self,
futex: &AtomicU32,
expected: u32,
timeout: Option<Duration>
) -> bool;
fn futex_wake(&self, futex: &AtomicU32) -> bool;
fn futex_wake_all(&self, futex: &AtomicU32);
fn spawn(&self, args: ThreadSpawnArgs) -> Result<u32, SpawnError>;
fn yield_now(&self);
fn set_name(&self, name: &CStr);
fn sleep(&self, duration: Duration);
fn join(&self, id: u32, timeout: Option<Duration>) -> Result<(), JoinError>;
fn tls_get_addr(&self, tls_index: &TlsIndex) -> Option<*const u8>;
}
Expand description
All the thread-related runtime functions.
Required Methods§
sourcefn available_parallelism(&self) -> NonZeroUsize
fn available_parallelism(&self) -> NonZeroUsize
Essentially number of threads on this system
sourcefn futex_wait(
&self,
futex: &AtomicU32,
expected: u32,
timeout: Option<Duration>
) -> bool
fn futex_wait( &self, futex: &AtomicU32, expected: u32, timeout: Option<Duration> ) -> bool
Wait for futex (see: Linux)
sourcefn futex_wake(&self, futex: &AtomicU32) -> bool
fn futex_wake(&self, futex: &AtomicU32) -> bool
Wake one for futex (see: Linux)
sourcefn futex_wake_all(&self, futex: &AtomicU32)
fn futex_wake_all(&self, futex: &AtomicU32)
Wake all for futex (see: Linux)
sourcefn spawn(&self, args: ThreadSpawnArgs) -> Result<u32, SpawnError>
fn spawn(&self, args: ThreadSpawnArgs) -> Result<u32, SpawnError>
Spawn a thread, returning an internal ID that uniquely identifies a thread in the runtime.
sourcefn join(&self, id: u32, timeout: Option<Duration>) -> Result<(), JoinError>
fn join(&self, id: u32, timeout: Option<Duration>) -> Result<(), JoinError>
Wait for the specified thread to terminate, or optionally time out.
sourcefn tls_get_addr(&self, tls_index: &TlsIndex) -> Option<*const u8>
fn tls_get_addr(&self, tls_index: &TlsIndex) -> Option<*const u8>
Implements the __tls_get_addr functionality. If the runtime feature is enabled, this crate defines the extern “C” function __tls_get_addr as a wrapper around calling this function after getting the runtime from get_runtime. If the provided index is invalid, return None.