Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add AbortHandle::is_aborted() #2710

Merged
merged 4 commits into from
Feb 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.
ZhennanWu marked this conversation as resolved.
Show resolved Hide resolved
pub fn is_aborted(&self) -> bool {
self.inner.aborted.load(Ordering::Relaxed)
}
}