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
Sleep(Duration)
CPU efficient with configurable sleep duration
Block
Blocking with efficient waiting (balanced performance/CPU)
Implementations§
Source§impl AutoWaitStrategy
impl AutoWaitStrategy
Sourcepub fn high_performance() -> Self
pub fn high_performance() -> Self
Create a high performance wait strategy (true busy spin)
Sourcepub fn high_performance_with_hints() -> Self
pub fn high_performance_with_hints() -> Self
Create a high performance wait strategy with spin loop hints
Sourcepub fn spin_then_yield(spins: usize) -> Self
pub fn spin_then_yield(spins: usize) -> Self
Create a hybrid strategy that spins N times then yields
Sourcepub fn cpu_efficient() -> Self
pub fn cpu_efficient() -> Self
Create a CPU efficient wait strategy
Sourcepub fn sleep_nanos(nanos: u64) -> Self
pub fn sleep_nanos(nanos: u64) -> Self
Create a sleep-based wait strategy with nanosecond precision
§Special Values
0= usespin_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.
Sourcepub fn sleep_micros(micros: u64) -> Self
pub fn sleep_micros(micros: u64) -> Self
Create a sleep-based wait strategy with microsecond precision
§Special Values
0= usespin_loop()instead of sleep (high performance)1..= Sleep for the specified microseconds (lower performance, CPU efficient)
Sourcepub fn from_env_or(default: AutoWaitStrategy) -> Self
pub fn from_env_or(default: AutoWaitStrategy) -> Self
Create wait strategy from environment variables with fallback
Checks these environment variables in order:
MYELON_AUTO_WAIT_DELAY_NS- nanosecond precision (0=spin_loop)MYELON_AUTO_WAIT_DELAY_US- microsecond precision (0=spin_loop)- 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=10Trait Implementations§
Source§impl Clone for AutoWaitStrategy
impl Clone for AutoWaitStrategy
Source§fn clone(&self) -> AutoWaitStrategy
fn clone(&self) -> AutoWaitStrategy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more