tiny_future

Crates.iotiny_future
lib.rstiny_future
version0.5.1
sourcesrc
created_at2018-06-30 21:18:05.997647
updated_at2022-08-04 18:15:12.269456
descriptionThis library provides a simple, `Condvar` based future with automatic cancellation on drop
homepage
repositoryhttps://github.com/KizzyCode/tiny_future-rust
max_upload_size
id72366
size16,657
Keziah Biermann (KizzyCode)

documentation

README

License License AppVeyor CI docs.rs crates.io Download numbers dependency status

tiny_future

Welcome to tiny_future 🎉

This library provides a simple, Condvar based future with automatic cancellation on drop.

Example

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);
Commit count: 27

cargo fmt