We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e6daa4f commit 67d2a17Copy full SHA for 67d2a17
src/task.rs
@@ -395,6 +395,19 @@ impl<T> Task<T> {
395
let header = ptr as *const Header;
396
unsafe { &*header }
397
}
398
+
399
+ /// Returns `true` if the current task is finished.
400
+ ///
401
+ /// Note that in a multithreaded environment, this task can change finish immediately after calling this function.
402
+ pub fn is_finished(&self) -> bool {
403
+ let ptr = self.ptr.as_ptr();
404
+ let header = ptr as *const Header;
405
406
+ unsafe {
407
+ let state = (*header).state.load(Ordering::Acquire);
408
+ state & (CLOSED | COMPLETED) != 0
409
+ }
410
411
412
413
impl<T> Drop for Task<T> {
0 commit comments