method Handle.cancel
Requests cooperative cancellation (§8.6).
Example:
fn forever() -> i64 time {
loop {
sleep(10ms)
}
}
fn main() io, time {
scope {
let h = spawn forever()
h.cancel()
match h.join() {
Cancelled _ => print("cancelled")
_ => print("finished")
}
}
}Output
cancelled
pub(api) fn cancel()Since. 1.0.0-beta
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/task.oxl:47