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

util: add documentation about cancel safety of SinkExt::send #6417

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tokio-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,20 @@
//! [`tokio`] crate. However, `tokio-util` _will_ respect Rust's
//! semantic versioning policy, especially with regard to breaking changes.
//!
//! # Cancellation safety
//!
//! When using `tokio::select!` in a loop to receive messages from multiple sources,
//! you should make sure that the receive call is cancellation safe to avoid
//! losing messages. This section goes through various common methods and
//! describes whether they are cancel safe. The lists in this section are not
//! exhaustive.
//!
//! * [`futures_util::sink::SinkExt::send`]: if send is used as the event in a
//! `tokio::select!` statement and some other branch completes first, then it is
//! guaranteed that the message was not sent, but the message itself is lost.
maminrayej marked this conversation as resolved.
Show resolved Hide resolved
//!
//! [`tokio`]: https://docs.rs/tokio
//! [`futures_util::sink::SinkExt::send`]: https://docs.rs/futures-util/latest/futures_util/sink/trait.SinkExt.html#method.send

#[macro_use]
mod cfg;
Expand Down
Loading