Crates.io | future-clicker |
lib.rs | future-clicker |
version | 0.1.1 |
source | src |
created_at | 2022-09-26 18:11:52.641613 |
updated_at | 2022-09-26 18:13:52.672733 |
description | Reimplementation of manual_future without using `futures` unstable |
homepage | |
repository | https://github.com/GothAck/future-clicker-rs |
max_upload_size | |
id | 674381 |
size | 11,943 |
A [Future
] value that resolves once it's explicitly completed, potentially
from a different thread or task, similar to Java's CompletableFuture
.
Currently, this is implemented using [Mutex
][parking_lot::Mutex] from the [parking_lot
] crate.
Create an incomplete [ControlledFuture
] and explicitly complete it with the
completer:
let (future, completer) = ControlledFuture::<i32>::new();
completer.complete(5).unwrap();
assert_eq!(block_on(future), Ok(5));
Create an initially complete [ControlledFuture
] that can be immediately
resolved:
assert_eq!(block_on(ControlledFuture::new_completed(10)), Ok(10));