mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-27 00:00:12 +02:00
net: clarify the cancellation safety of the TcpStream::peek (#7305)
This commit is contained in:
@@ -1070,6 +1070,13 @@ impl TcpStream {
|
|||||||
/// Successive calls return the same data. This is accomplished by passing
|
/// Successive calls return the same data. This is accomplished by passing
|
||||||
/// `MSG_PEEK` as a flag to the underlying `recv` system call.
|
/// `MSG_PEEK` as a flag to the underlying `recv` system call.
|
||||||
///
|
///
|
||||||
|
/// # Cancel safety
|
||||||
|
///
|
||||||
|
/// This method is cancel safe. If the method is used as the event in a
|
||||||
|
/// [`tokio::select!`](crate::select) statement and some other branch
|
||||||
|
/// completes first, then it is guaranteed that no peek was performed, and
|
||||||
|
/// that `buf` has not been modified.
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
|
|||||||
Reference in New Issue
Block a user