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§

source

fn available_parallelism(&self) -> NonZeroUsize

Essentially number of threads on this system

source

fn futex_wait( &self, futex: &AtomicU32, expected: u32, timeout: Option<Duration> ) -> bool

Wait for futex (see: Linux)

source

fn futex_wake(&self, futex: &AtomicU32) -> bool

Wake one for futex (see: Linux)

source

fn futex_wake_all(&self, futex: &AtomicU32)

Wake all for futex (see: Linux)

source

fn spawn(&self, args: ThreadSpawnArgs) -> Result<u32, SpawnError>

Spawn a thread, returning an internal ID that uniquely identifies a thread in the runtime.

source

fn yield_now(&self)

Yield calling thread

source

fn set_name(&self, name: &CStr)

Set the name of calling thread

source

fn sleep(&self, duration: Duration)

Sleep calling thread

source

fn join(&self, id: u32, timeout: Option<Duration>) -> Result<(), JoinError>

Wait for the specified thread to terminate, or optionally time out.

source

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.

Implementors§