Struct sync_wait_object::windows::ManualResetEvent
source · pub struct ManualResetEvent(_);Expand description
Wrapper of WaitEvent of type bool, which focuses on waiting for true without resetting.
Examples
The example does not make sense (as [sync_wait_object::WaitEvent] of u8 makes more sense for this scenario), it is just for demonstration.
use std::{ thread, sync::Arc, sync::atomic::{ AtomicU8, Ordering } };
use sync_wait_object::SignalWaitable;
let ev = ManualResetEvent::new();
let mut signal = ev.clone();
let v = Arc::new(AtomicU8::new(0));
let v_setter = v.clone();
thread::spawn(move || {
v_setter.store(1, Ordering::SeqCst);
signal.set().unwrap();
});
ev.wait_until_set().unwrap();
assert_eq!(v.load(Ordering::SeqCst), 1);
Implementations§
Trait Implementations§
source§impl Clone for ManualResetEvent
impl Clone for ManualResetEvent
source§fn clone(&self) -> ManualResetEvent
fn clone(&self) -> ManualResetEvent
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more