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
2 people authored and taiki-e committed Mar 11, 2023
1 parent 5b64af3 commit 9c44e14
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions futures-util/src/abortable.rs
Original file line number Diff line number Diff line change
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 9c44e14

Please sign in to comment.