Welcome to tiny_future
🎉
This library provides a simple, Condvar
based future with automatic cancellation on drop.
use std::{thread, time::Duration};
// Create futures
let (setter, getter) = tiny_future::new::<u8>();
// Run something in a separate task
thread::spawn(move || {
// Do some computations and set the result
thread::sleep(Duration::from_secs(1));
setter.set(7);
});
// Wait unil the result is available
let result = getter.wait().expect("Failed to compute result");
assert_eq!(result, 7);