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§
- Wait
Handle Listener - The listening half of a wait handle.
- Wait
Handle Signaler - The signaling half of a wait handle.
Enums§
- Wait
Handle Error - Represents a wait handle error.
Functions§
- new
- Creates a wait handle pair for signaling and listening.
Type Aliases§
- Wait
Handle Result - The result of a wait handle operation.