Skip to main content

AutoWaitStrategy

Enum AutoWaitStrategy 

Source
pub enum AutoWaitStrategy {
    BusySpin,
    BusySpinWithSpinLoopHint,
    SpinThenYield {
        spins: usize,
    },
    Sleep(Duration),
    Block,
}
Expand description

Wait strategy for automatic event handlers

Variants§

§

BusySpin

Maximum performance busy spinning (100% CPU usage) - true busy spin, no hints

§

BusySpinWithSpinLoopHint

High performance busy spinning with spin loop hints (slightly lower CPU usage)

§

SpinThenYield

Hybrid: spin N iterations, then yield the thread

Fields

§spins: usize

Number of spin-loop iterations before yielding once.

§

Sleep(Duration)

CPU efficient with configurable sleep duration

§

Block

Blocking with efficient waiting (balanced performance/CPU)

Implementations§

Source§

impl AutoWaitStrategy

Source

pub fn high_performance() -> Self

Create a high performance wait strategy (true busy spin)

Source

pub fn high_performance_with_hints() -> Self

Create a high performance wait strategy with spin loop hints

Source

pub fn spin_then_yield(spins: usize) -> Self

Create a hybrid strategy that spins N times then yields

Source

pub fn cpu_efficient() -> Self

Create a CPU efficient wait strategy

Source

pub fn sleep(duration: Duration) -> Self

Create a custom sleep-based wait strategy

Source

pub fn sleep_nanos(nanos: u64) -> Self

Create a sleep-based wait strategy with nanosecond precision

§Special Values
  • 0 = use spin_loop() instead of sleep (high performance)
  • 1.. = Sleep for the specified nanoseconds (lower performance, CPU efficient)

Note: Actual sleep precision depends on the operating system. Very small durations (< 1000ns) may not sleep at all on some systems.

Source

pub fn sleep_micros(micros: u64) -> Self

Create a sleep-based wait strategy with microsecond precision

§Special Values
  • 0 = use spin_loop() instead of sleep (high performance)
  • 1.. = Sleep for the specified microseconds (lower performance, CPU efficient)
Source

pub fn from_env_or(default: AutoWaitStrategy) -> Self

Create wait strategy from environment variables with fallback

Checks these environment variables in order:

  1. MYELON_AUTO_WAIT_DELAY_NS - nanosecond precision (0 = spin_loop)
  2. MYELON_AUTO_WAIT_DELAY_US - microsecond precision (0 = spin_loop)
  3. Falls back to the provided default
§Examples
# Use spin_loop (maximum performance)
export MYELON_AUTO_WAIT_DELAY_NS=0

# Sleep for 100 nanoseconds
export MYELON_AUTO_WAIT_DELAY_NS=100

# Sleep for 10 microseconds
export MYELON_AUTO_WAIT_DELAY_US=10

Trait Implementations§

Source§

impl Clone for AutoWaitStrategy

Source§

fn clone(&self) -> AutoWaitStrategy

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AutoWaitStrategy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AutoWaitStrategy

Source§

fn default() -> AutoWaitStrategy

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V