pub struct ManualResetEvent(/* private fields */);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 duplicate 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 moreSource§impl Deref for ManualResetEvent
impl Deref for ManualResetEvent
Auto Trait Implementations§
impl Freeze for ManualResetEvent
impl RefUnwindSafe for ManualResetEvent
impl Send for ManualResetEvent
impl Sync for ManualResetEvent
impl Unpin for ManualResetEvent
impl UnwindSafe for ManualResetEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more