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

Implement Clone for AbortHandle #6621

Merged
merged 2 commits into from
Jun 7, 2024

Conversation

aschweig
Copy link
Contributor

@aschweig aschweig commented Jun 6, 2024

This is a small change so that AbortHandle implements Clone.

Motivation

The the module level docs indicate

Each task can only have one JoinHandle, but it can have more than one AbortHandle.

Cloning is convenient for AbortHandles given there can be more than one.

Solution

The proposed solution is similar to JoinHandle's abort_handle method:

impl Clone for AbortHandle {
    /// Returns a cloned `AbortHandle` that can be used to remotely abort this task.
    fn clone(&self) -> Self {
        self.raw.ref_inc();
        Self::new(self.raw)
    }
}

@github-actions github-actions bot added R-loom-current-thread Run loom current-thread tests on this PR R-loom-multi-thread Run loom multi-thread tests on this PR R-loom-multi-thread-alt Run loom multi-thread alt tests on this PR labels Jun 6, 2024
@Darksonn Darksonn added A-tokio Area: The main tokio crate M-task Module: tokio/task labels Jun 7, 2024
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

@Darksonn Darksonn merged commit 126ce89 into tokio-rs:master Jun 7, 2024
88 checks passed
This was referenced Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-task Module: tokio/task R-loom-current-thread Run loom current-thread tests on this PR R-loom-multi-thread Run loom multi-thread tests on this PR R-loom-multi-thread-alt Run loom multi-thread alt tests on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants