Skip to content

Commit

Permalink
Add AbortRegistration::handle (#2712)
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 8292ff9 commit 1f3f059
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions futures-util/src/abortable.rs
Expand Up @@ -78,6 +78,17 @@ pub struct AbortRegistration {
pub(crate) inner: Arc<AbortInner>,
}

impl AbortRegistration {
/// Create an [`AbortHandle`] from the given [`AbortRegistration`].
///
/// The created [`AbortHandle`] is functionally the same as any other
/// [`AbortHandle`]s that are associated with the same [`AbortRegistration`],
/// such as the one created by [`AbortHandle::new_pair`].
pub fn handle(&self) -> AbortHandle {
AbortHandle { inner: self.inner.clone() }
}
}

/// A handle to an `Abortable` task.
#[derive(Debug, Clone)]
pub struct AbortHandle {
Expand Down

0 comments on commit 1f3f059

Please sign in to comment.