Expand description
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§
- The listening half of a wait handle.
- The signaling half of a wait handle.
Enums§
- Represents a wait handle error.
Functions§
- Creates a wait handle pair for signaling and listening.
Type Aliases§
- The result of a wait handle operation.