waitable 0.1.0

A synchronized (atomic) value container implementing the Mutex+Condvar pattern for efficient blocking waits
Documentation
  • Coverage
  • 100%
    7 out of 7 items documented1 out of 6 items with examples
  • Size
  • Source code size: 10.97 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.43 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • aib/waitable
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • aib

Waitable

A synchronized (atomic) value container implementing the Mutex+Condvar pattern for efficient blocking waits

Usage

use std::sync::Arc;
use waitable::Waitable;

let w = Arc::new(Waitable::new(0));

println!("Spawning thread...");

let join_handle = {
	let w = w.clone();
	std::thread::spawn(move || {
		println!("Thread waiting...");
		w.wait(&42);
		println!("Thread done waiting");
	})
};

println!("Waiting to set...");
std::thread::sleep(std::time::Duration::from_millis(500));

println!("Setting...");
w.set(42);

join_handle.join().unwrap();
println!("All done");
Spawning thread...
Waiting to set...
Thread waiting...
Setting...
Thread done waiting
All done