tokio-rs / website

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

Added cancellation-token content in Graceful Shutdown topic docs #695

Closed stanwolverine closed 1 year ago

stanwolverine commented 1 year ago

Cancellation Tokens should be used to notify task to shut down instead of broadcast channels. Therefore, I replaced usage of Broadcast Channel in Telling things to shut down section of Graceful Shutdown topic docs with Cancellation Tokens

closes #694

Darksonn commented 1 year ago

Generally, to share a token between multiple tasks, you need to clone it. It would be good to include a bit about that. Also, I don't think your example compiles due to this issue.

stanwolverine commented 1 year ago

@Darksonn You are right. My example was not compiling due to ownership rule. I have included token cloning in doc and code snippet.