[][src]Crate waithandle

A library that makes signaling between threads a bit more ergonomic than using a CondVar + Mutex directly.

Examples

use std::thread;

let (signaler, listener) = waithandle::new();

let thread = thread::spawn({
    move || {
        while !listener.check().unwrap() {
            println!("Doing some work...");
            if listener.wait(Duration::from_secs(1)).unwrap() {
                println!("Someone told us to exit!");
                break;
            }
        }
    }
});

thread::sleep(Duration::from_secs(5));

println!("Signaling thread...");
signaler.signal().unwrap();
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.