Skip to content
Experimental cooperative cancellation for async-std
Rust
Branch: master
Clone or download
Latest commit d9cef9b Nov 12, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows
src fix channel capacity panic Nov 9, 2019
tests Fix a panic on TokenSource creation Nov 9, 2019
.gitignore initial Nov 3, 2019
Cargo.toml Switch to async-std 1.0 Nov 12, 2019
README.md initial Nov 3, 2019

README.md

Cooperative cancellation for async-std.

Status: experimental.

See crate docs for details

use stop_token::StopToken;

async fn do_work(work: impl Stream<Item = Event>, stop_token: StopToken) {
    // The `work` stream will end early: as soon as `stop_token` is cancelled. 
    let mut work = stop_token.stop_stream(work);
    while let Some(event) = work.next().await {
        process_event(event).await
    }
}
You can’t perform that action at this time.