Crates.io | futures-shuttle |
lib.rs | futures-shuttle |
version | 0.2.1 |
source | src |
created_at | 2018-03-14 16:27:54.885305 |
updated_at | 2018-04-07 05:20:40.533624 |
description | Futures-aware shuttle synchronization object |
homepage | |
repository | https://gitlab.com/imp/futures-shuttle-rs.git |
max_upload_size | |
id | 55639 |
size | 28,895 |
Futures-aware shuttle synchronization object
Creates a new shuttle synchronization object for sharing values between two asynchronous tasks. Each half can be separately owned and sent across tasks.
extern crate futures;
extern crate futures_shuttle;
use std::thread;
use futures_shuttle::shuttle;
use futures::*;
fn main() {
let (mut left, mut right) = shuttle(42);
assert!(left.is_mine());
assert!(!right.is_mine());
assert_eq!(left.get(), 42);
left.set(84);
left.send();
assert!(!left.is_mine());
assert!(right.is_mine());
assert_eq!(right.get(), 84);
}