[−][src]Crate waithandle
A library that makes signaling between threads a bit more ergonomic
than using a CondVar
+ Mutex
directly.
Examples
use std::thread; use std::time::Duration; let (signaler, listener) = waithandle::new(); let thread = thread::spawn({ move || { while !listener.check() { println!("Doing some work..."); // Wait for 1 second or until we receive a signal if listener.wait(Duration::from_secs(1)) { println!("Someone told us to quit!"); break; } } } }); // Sleep for 5 seconds. thread::sleep(Duration::from_secs(5)); println!("Signaling thread..."); signaler.signal(); println!("Joining thread..."); thread.join().unwrap();
Structs
WaitHandleListener | The listening half of a wait handle. |
WaitHandleSignaler | The signaling half of a wait handle. |
Enums
WaitHandleError | Represents a wait handle error. |
Functions
new | Creates a wait handle pair for signaling and listening. |
Type Definitions
WaitHandleResult | The result of a wait handle operation. |