File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,16 @@ pub using @event_loop {sleep}
3838/// `pause` can be used to avoid starving other tasks.
3939pub using @coroutine {pause }
4040
41+ ///|
42+ /// Returns `true` if current task is being cancelled.
43+ /// In this case, all work should be stopped except cleanup jobs.
44+ /// Usually there is no need to check for cancellation manually,
45+ /// the cancellation error will automatically get things done.
46+ /// However, some patterns, such as writing catch all error handler
47+ /// inside loop body, may result in infinite loop on cancellation.
48+ /// In this case, `is_being_cancelled` can be used to avoid dead loop.
49+ pub using @coroutine {is_being_cancelled }
50+
4151///|
4252pub suberror TimeoutError derive (Show )
4353
Original file line number Diff line number Diff line change 88)
99
1010// Values
11+ fn is_being_cancelled() -> Bool
12+
1113fn now() -> Int64
1214
1315async fn pause() -> Unit
You can’t perform that action at this time.
0 commit comments