Skip to content

Commit 4266221

Browse files
ZhennanWuznjameswu
authored andcommitted
Add AbortRegistration::handle (#2712)
Co-authored-by: ZhennanWu <[email protected]>
1 parent 9c44e14 commit 4266221

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

+11
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ pub struct AbortRegistration {
7878
pub(crate) inner: Arc<AbortInner>,
7979
}
8080

81+
impl AbortRegistration {
82+
/// Create an [`AbortHandle`] from the given [`AbortRegistration`].
83+
///
84+
/// The created [`AbortHandle`] is functionally the same as any other
85+
/// [`AbortHandle`]s that are associated with the same [`AbortRegistration`],
86+
/// such as the one created by [`AbortHandle::new_pair`].
87+
pub fn handle(&self) -> AbortHandle {
88+
AbortHandle { inner: self.inner.clone() }
89+
}
90+
}
91+
8192
/// A handle to an `Abortable` task.
8293
#[derive(Debug, Clone)]
8394
pub struct AbortHandle {

0 commit comments

Comments
 (0)