[−][src]Crate cancel
This crate provides a Token
that can be used to co-operatively
signal when an operation should be canceled.
use cancel::{Canceled, Token}; use std::time::Duration; fn do_something(token: &Token) -> Result<bool, Canceled> { loop { token.check_cancel()?; // process more stuff here } Ok(true) } fn start_something() -> Result<bool, Canceled> { let token = Token::with_duration(Duration::new(10, 0)); do_something(&token) }
Structs
Canceled | The Err value returned from |
Token | A cancellation token.
It tracks the state and holds an optional deadline for the operation.
To share |