Repository: tokio-rs/tokio
File: tokio/src/runtime/task/abort.rs (Rust)

Code before:
impl AbortHandle {
    pub(super) fn new(raw: Option<RawTask>, id: Id) -> Self {
        Self { raw, id }
    }

    /// Abort the task associated with the handle.
    ///
    /// Awaiting a cancelled task might complete as usual if the task was
    /// already completed at the time it was cancelled, but most likely it
    /// will fail with a [cancelled] `JoinError`.
    ///
    /// If the task was already cancelled, such as by [`JoinHandle::abort`],
    /// this method will do nothing.
    ///
    /// [cancelled]: method@super::error::JoinError::is_cancelled
    /// [`JoinHandle::abort`]: method@super::JoinHandle::abort
    // the `AbortHandle` type is only publicly exposed when `tokio_unstable` is
    // enabled, but it is still defined for testing purposes.
    #[cfg_attr(not(tokio_unstable), allow(unreachable_pub))]
    pub fn abort(&self) {
        if let Some(ref raw) = self.raw {
            raw.remote_abort();
        }
    }

    /// Checks if the task associated with this `JoinHandle` has finished.
    ///
    /// Please note that this method can return `false` even if `abort` has been
    /// called on the task. This is because the cancellation process may take
    /// some time, and this method does not return `true` until it has
    /// completed.
    #[cfg_attr(not(tokio_unstable), allow(unreachable_pub))]
    pub fn is_finished(&self) -> bool {
        if let Some(raw) = self.raw {
            let state = raw.header().state.load();
            state.is_complete()
        } else {
            true
        }
    }

    /// Returns a [task ID] that uniquely identifies this task relative to other
    /// currently spawned tasks.
    ///
    /// **Note**: This is an [unstable API][unstable]. The public API of this type
    /// may break in 1.x releases. See [the documentation on unstable
    /// features][unstable] for details.
    ///
    /// [task ID]: crate::task::Id
    /// [unstable]: crate#unstable-features
    #[cfg(tokio_unstable)]

Review comment (suggestion):
```suggestion
    /// Checks if the task associated with this `AbortHandle` has finished.
```

Code after:
impl AbortHandle {
    pub(super) fn new(raw: Option<RawTask>, id: Id) -> Self {
        Self { raw, id }
    }

    /// Abort the task associated with the handle.
    ///
    /// Awaiting a cancelled task might complete as usual if the task was
    /// already completed at the time it was cancelled, but most likely it
    /// will fail with a [cancelled] `JoinError`.
    ///
    /// If the task was already cancelled, such as by [`JoinHandle::abort`],
    /// this method will do nothing.
    ///
    /// [cancelled]: method@super::error::JoinError::is_cancelled
    /// [`JoinHandle::abort`]: method@super::JoinHandle::abort
    // the `AbortHandle` type is only publicly exposed when `tokio_unstable` is
    // enabled, but it is still defined for testing purposes.
    #[cfg_attr(not(tokio_unstable), allow(unreachable_pub))]
    pub fn abort(&self) {
        if let Some(ref raw) = self.raw {
            raw.remote_abort();
        }
    }

    /// Checks if the task associated with this `AbortHandle` has finished.
    ///
    /// Please note that this method can return `false` even if `abort` has been
    /// called on the task. This is because the cancellation process may take
    /// some time, and this method does not return `true` until it has
    /// completed.
    #[cfg_attr(not(tokio_unstable), allow(unreachable_pub))]
    pub fn is_finished(&self) -> bool {
        if let Some(raw) = self.raw {
            let state = raw.header().state.load();
            state.is_complete()
        } else {
            true
        }
    }

    /// Returns a [task ID] that uniquely identifies this task relative to other
    /// currently spawned tasks.
    ///
    /// **Note**: This is an [unstable API][unstable]. The public API of this type
    /// may break in 1.x releases. See [the documentation on unstable
    /// features][unstable] for details.
    ///
    /// [task ID]: crate::task::Id
    /// [unstable]: crate#unstable-features
    #[cfg(tokio_unstable)]