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

Cancel safety of tokio::task::JoinHandle is not documented #4679

Closed
tbu- opened this issue May 11, 2022 · 4 comments · Fixed by #4901
Closed

Cancel safety of tokio::task::JoinHandle is not documented #4679

tbu- opened this issue May 11, 2022 · 4 comments · Fixed by #4901
Labels
A-tokio Area: The main tokio crate C-bug Category: This is a bug. M-macros Module: macros in the main Tokio crate M-task Module: tokio/task T-docs Topic: documentation

Comments

@tbu-
Copy link
Contributor

tbu- commented May 11, 2022

Neither in the documentation of JoinHandle nor in the "Cancellation safety" of the select! macro.

@tbu- tbu- added A-tokio Area: The main tokio crate C-bug Category: This is a bug. labels May 11, 2022
@Darksonn Darksonn added M-task Module: tokio/task M-macros Module: macros in the main Tokio crate labels May 11, 2022
@Darksonn
Copy link
Contributor

Well, cancelling something is done by dropping it, so once you've "cancelled" the JoinHandle, you don't have it anymore. It should say what happens when you drop it. On the other hand, if you use a mutable reference to the join handle in the select, then it isn't actually being cancelled at all.

@Darksonn Darksonn added the T-docs Topic: documentation label Jun 16, 2022
@Darksonn Darksonn closed this as not planned Won't fix, can't repro, duplicate, stale Aug 10, 2022
@tbu-
Copy link
Contributor Author

tbu- commented Aug 11, 2022

Can you explain why it is not planned? The documentation of select! tells me that I need to be careful about using it with futures, that I need to determine whether they're cancellation safe. It lists a few futures, but JoinHandle isn't one of them. How should I, as a user, determine whether it (or a mutable reference to it) is cancellation safe?

@Darksonn Darksonn reopened this Aug 11, 2022
@Darksonn
Copy link
Contributor

Cancellation safety does not apply to JoinHandle at all because if you cancel it, the JoinHandle is lost and you cannot use it again. Anyway, I suppose it would be good to explain the situation in the docs regardless, so I have reopened the issue.

@tbu-
Copy link
Contributor Author

tbu- commented Aug 20, 2022

Thanks!

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 C-bug Category: This is a bug. M-macros Module: macros in the main Tokio crate M-task Module: tokio/task T-docs Topic: documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants