Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gothack/future-clicker-rs
Reimplementation of manual_future without using `futures` unstable
https://github.com/gothack/future-clicker-rs
Last synced: 5 days ago
JSON representation
Reimplementation of manual_future without using `futures` unstable
- Host: GitHub
- URL: https://github.com/gothack/future-clicker-rs
- Owner: GothAck
- Created: 2022-09-26T17:56:52.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-09-26T18:13:36.000Z (about 2 years ago)
- Last Synced: 2024-10-13T17:21:34.060Z (about 1 month ago)
- Language: Rust
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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`][parking_lot::Mutex] from the [`parking_lot`] crate.
# Examples
Create an incomplete [`ControlledFuture`] and explicitly complete it with the
completer:
```rust
let (future, completer) = ControlledFuture::::new();
completer.complete(5).unwrap();
assert_eq!(block_on(future), Ok(5));
```Create an initially complete [`ControlledFuture`] that can be immediately
resolved:
```rust
assert_eq!(block_on(ControlledFuture::new_completed(10)), Ok(10));
```