Skip to content

Commit

Permalink
add AbortHandle::is_aborted() (#2710)
Browse files Browse the repository at this point in the history
Co-authored-by: ZhennanWu <znjameswu@gmail.com>
  • Loading branch information
ZhennanWu and znjameswu committed Feb 19, 2023
1 parent b41ede5 commit d757d87
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions futures-util/src/abortable.rs
Expand Up @@ -182,4 +182,17 @@ impl AbortHandle {
self.inner.aborted.store(true, Ordering::Relaxed);
self.inner.waker.wake();
}

/// Checks whether [`AbortHandle::abort`] was *called* on any associated
/// [`AbortHandle`]s, which includes all the [`AbortHandle`]s linked with
/// the same [`AbortRegistration`]. This means that it will return `true`
/// even if:
/// * `abort` was called after the task had completed.
/// * `abort` was called while the task was being polled - the task may still be running and
/// will not be stopped until `poll` returns.
///
/// This operation has a Relaxed ordering.
pub fn is_aborted(&self) -> bool {
self.inner.aborted.load(Ordering::Relaxed)
}
}

0 comments on commit d757d87

Please sign in to comment.