tokio-rs / website

Website for the Tokio project
https://tokio.rs
MIT License
228 stars 329 forks source link

Tokio's tutorial does not mention CancellationToken #694

Closed Finomnis closed 1 year ago

Finomnis commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

I agree, my bad. Point stands, though.

Darksonn commented 1 year ago

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

Darksonn commented 1 year ago

I opened https://github.com/tokio-rs/tokio/issues/5585 for the mpsc replacement.

stanwolverine commented 1 year ago

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

Darksonn commented 1 year ago

Yeah, pretty much.