2 releases
| 0.1.1 | Sep 26, 2022 |
|---|---|
| 0.1.0 | Sep 26, 2022 |
#1016 in Asynchronous
36 downloads per month
11KB
161 lines
completable
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 from the parking_lot crate.
Examples
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));
lib.rs:
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 from the parking_lot crate.
Examples
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));
Dependencies
~1–6.5MB
~36K SLoC