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

io: document cancel safety of AsyncReadExt's primitive read functions #6337

Merged
merged 1 commit into from
Feb 11, 2024
Merged
Changes from all commits
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
132 changes: 132 additions & 0 deletions tokio/src/io/util/async_read_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is cancel safe. If this method is used as an event in a
/// [`tokio::select!`](crate::select) statement and some other branch
/// completes first, it is guaranteed that no data were read.
///
/// # Examples
///
/// Read unsigned 8 bit integers from an `AsyncRead`:
Expand Down Expand Up @@ -368,6 +374,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is cancel safe. If this method is used as an event in a
/// [`tokio::select!`](crate::select) statement and some other branch
/// completes first, it is guaranteed that no data were read.
///
/// # Examples
///
/// Read unsigned 8 bit integers from an `AsyncRead`:
Expand Down Expand Up @@ -407,6 +419,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read unsigned 16 bit big-endian integers from a `AsyncRead`:
Expand Down Expand Up @@ -445,6 +463,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read signed 16 bit big-endian integers from a `AsyncRead`:
Expand Down Expand Up @@ -483,6 +507,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read unsigned 32-bit big-endian integers from a `AsyncRead`:
Expand Down Expand Up @@ -521,6 +551,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read signed 32-bit big-endian integers from a `AsyncRead`:
Expand Down Expand Up @@ -558,6 +594,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read unsigned 64-bit big-endian integers from a `AsyncRead`:
Expand Down Expand Up @@ -597,6 +639,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read signed 64-bit big-endian integers from a `AsyncRead`:
Expand Down Expand Up @@ -634,6 +682,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read unsigned 128-bit big-endian integers from a `AsyncRead`:
Expand Down Expand Up @@ -674,6 +728,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read signed 128-bit big-endian integers from a `AsyncRead`:
Expand Down Expand Up @@ -714,6 +774,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read 32-bit floating point type from a `AsyncRead`:
Expand Down Expand Up @@ -751,6 +817,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read 64-bit floating point type from a `AsyncRead`:
Expand Down Expand Up @@ -790,6 +862,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read unsigned 16 bit little-endian integers from a `AsyncRead`:
Expand Down Expand Up @@ -828,6 +906,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read signed 16 bit little-endian integers from a `AsyncRead`:
Expand Down Expand Up @@ -866,6 +950,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read unsigned 32-bit little-endian integers from a `AsyncRead`:
Expand Down Expand Up @@ -904,6 +994,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read signed 32-bit little-endian integers from a `AsyncRead`:
Expand Down Expand Up @@ -941,6 +1037,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read unsigned 64-bit little-endian integers from a `AsyncRead`:
Expand Down Expand Up @@ -980,6 +1082,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read signed 64-bit little-endian integers from a `AsyncRead`:
Expand Down Expand Up @@ -1017,6 +1125,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read unsigned 128-bit little-endian integers from a `AsyncRead`:
Expand Down Expand Up @@ -1057,6 +1171,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read signed 128-bit little-endian integers from a `AsyncRead`:
Expand Down Expand Up @@ -1097,6 +1217,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read 32-bit floating point type from a `AsyncRead`:
Expand Down Expand Up @@ -1134,6 +1260,12 @@ cfg_io_util! {
///
/// [`AsyncReadExt::read_exact`]: AsyncReadExt::read_exact
///
/// # Cancel safety
///
/// This method is not cancellation safe. If the method is used as the
/// event in a [`tokio::select!`](crate::select) statement and some
/// other branch completes first, then some data may be lost.
///
/// # Examples
///
/// Read 64-bit floating point type from a `AsyncRead`:
Expand Down
Loading