Skip to content

Commit 9c44e14

Browse files
ZhennanWuznjameswu
authored andcommitted
add AbortHandle::is_aborted() (#2710)
Co-authored-by: ZhennanWu <[email protected]>
1 parent 5b64af3 commit 9c44e14

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Diff for: futures-util/src/abortable.rs

+13
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,17 @@ impl AbortHandle {
182182
self.inner.aborted.store(true, Ordering::Relaxed);
183183
self.inner.waker.wake();
184184
}
185+
186+
/// Checks whether [`AbortHandle::abort`] was *called* on any associated
187+
/// [`AbortHandle`]s, which includes all the [`AbortHandle`]s linked with
188+
/// the same [`AbortRegistration`]. This means that it will return `true`
189+
/// even if:
190+
/// * `abort` was called after the task had completed.
191+
/// * `abort` was called while the task was being polled - the task may still be running and
192+
/// will not be stopped until `poll` returns.
193+
///
194+
/// This operation has a Relaxed ordering.
195+
pub fn is_aborted(&self) -> bool {
196+
self.inner.aborted.load(Ordering::Relaxed)
197+
}
185198
}

0 commit comments

Comments
 (0)