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

Tokio's tutorial does not mention CancellationToken #694

Closed
Finomnis opened this issue Mar 25, 2023 · 6 comments · Fixed by #695
Closed

Tokio's tutorial does not mention CancellationToken #694

Finomnis opened this issue Mar 25, 2023 · 6 comments · Fixed by #695

Comments

@Finomnis
Copy link

https://tokio.rs/tokio/topics/shutdown

This example uses an mpsc to propagate a shutdown request, while the recommended way of shutting down is CancellationToken.

I guess this was because CancellationToken wasn't stable enough yet; but after the zero-unsafe rewrite, it should be stable enough now.

Solution

Adjust the documentation so it mentions CancellationToken in the page about shutting down.

@Darksonn
Copy link
Contributor

Darksonn commented Mar 25, 2023

I agree, but the thing CancellationToken replaces is the "Telling things to shut down" section, and not the part where an mpsc channel is used.

@Finomnis
Copy link
Author

I agree, my bad. Point stands, though.

@Darksonn
Copy link
Contributor

Yes, definitely. Perhaps it would be worth creating a tool to replace the mspc channel as well.

@Darksonn
Copy link
Contributor

I opened tokio-rs/tokio#5585 for the mpsc replacement.

@stanwolverine
Copy link
Contributor

@Darksonn Does this mean we have to replace broadcast channel with CancellationToken in "Telling things to shut down" section of the doc?

@Darksonn
Copy link
Contributor

Yeah, pretty much.

stanwolverine added a commit to stanwolverine/tokio-rs-website that referenced this issue Mar 29, 2023
Cancellation Tokens should be used to notify task to shut down instead of broadcast channels

closes tokio-rs#694
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants