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: clarify clear_ready and clear_ready_matching documentation #6304

Merged
merged 5 commits into from
Jan 27, 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
16 changes: 16 additions & 0 deletions tokio/src/io/async_fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,10 @@ impl<'a, Inner: AsRawFd> AsyncFdReadyGuard<'a, Inner> {
/// _actually observes_ that the file descriptor is _not_ ready. Do not call
/// it simply because, for example, a read succeeded; it should be called
/// when a read is observed to block.
///
/// This method only clears readiness events that happened before the creation of this guard.
/// In other words, if the IO resource becomes ready between the creation of the guard and
/// this call to `clear_ready`, then the readiness is not actually cleared.
pub fn clear_ready(&mut self) {
if let Some(event) = self.event.take() {
self.async_fd.registration.clear_readiness(event);
Expand All @@ -846,6 +850,10 @@ impl<'a, Inner: AsRawFd> AsyncFdReadyGuard<'a, Inner> {
/// block. For example when a read blocks when using a combined interest,
/// only clear `Ready::READABLE`.
///
/// This method only clears readiness events that happened before the creation of this guard.
/// In other words, if the IO resource becomes ready between the creation of the guard and
/// this call to `clear_ready`, then the readiness is not actually cleared.
///
/// # Examples
///
/// Concurrently read and write to a [`std::net::TcpStream`] on the same task without
Expand Down Expand Up @@ -1042,6 +1050,10 @@ impl<'a, Inner: AsRawFd> AsyncFdReadyMutGuard<'a, Inner> {
/// _actually observes_ that the file descriptor is _not_ ready. Do not call
/// it simply because, for example, a read succeeded; it should be called
/// when a read is observed to block.
///
/// This method only clears readiness events that happened before the creation of this guard.
/// In other words, if the IO resource becomes ready between the creation of the guard and
/// this call to `clear_ready`, then the readiness is not actually cleared.
pub fn clear_ready(&mut self) {
if let Some(event) = self.event.take() {
self.async_fd.registration.clear_readiness(event);
Expand All @@ -1062,6 +1074,10 @@ impl<'a, Inner: AsRawFd> AsyncFdReadyMutGuard<'a, Inner> {
/// block. For example when a read blocks when using a combined interest,
/// only clear `Ready::READABLE`.
///
/// This method only clears readiness events that happened before the creation of this guard.
/// In other words, if the IO resource becomes ready between the creation of the guard and
/// this call to `clear_ready`, then the readiness is not actually cleared.
///
/// # Examples
///
/// Concurrently read and write to a [`std::net::TcpStream`] on the same task without
Expand Down
Loading