Skip to content

Commit

Permalink
rename clear_ready_exact -> clear_ready_matching
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev committed May 24, 2023
1 parent 920c550 commit 3cec780
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions tokio/src/io/async_fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ impl<T: AsRawFd> AsyncFd<T> {
/// When a combined interest is used, it is important to clear only the readiness
/// that is actually observed to block. For instance when the combined
/// interest `Interest::READABLE | Interest::WRITABLE` is used, and a read blocks, only
/// read readiness should be cleared using the [`AsyncFdReadyGuard::clear_ready_exact`] method:
/// `guard.clear_ready_exact(Ready::READABLE)`.
/// read readiness should be cleared using the [`AsyncFdReadyGuard::clear_ready_matching`] method:
/// `guard.clear_ready_matching(Ready::READABLE)`.
/// Also clearing the write readiness in this case would be incorrect. The [`AsyncFdReadyGuard::clear_ready`]
/// method clears all readiness flags.
///
Expand Down Expand Up @@ -501,7 +501,7 @@ impl<T: AsRawFd> AsyncFd<T> {
/// Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
/// // a read has blocked, but a write might still succeed.
/// // clear only the read readiness.
/// guard.clear_ready_exact(Ready::READABLE);
/// guard.clear_ready_matching(Ready::READABLE);
/// continue;
/// }
/// Err(e) => {
Expand All @@ -520,7 +520,7 @@ impl<T: AsRawFd> AsyncFd<T> {
/// Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
/// // a write has blocked, but a read might still succeed.
/// // clear only the write readiness.
/// guard.clear_ready_exact(Ready::WRITABLE);
/// guard.clear_ready_matching(Ready::WRITABLE);
/// continue;
/// }
/// Err(e) => {
Expand Down Expand Up @@ -554,8 +554,8 @@ impl<T: AsRawFd> AsyncFd<T> {
/// When a combined interest is used, it is important to clear only the readiness
/// that is actually observed to block. For instance when the combined
/// interest `Interest::READABLE | Interest::WRITABLE` is used, and a read blocks, only
/// read readiness should be cleared using the [`AsyncFdReadyMutGuard::clear_ready_exact`] method:
/// `guard.clear_ready_exact(Ready::READABLE)`.
/// read readiness should be cleared using the [`AsyncFdReadyMutGuard::clear_ready_matching`] method:
/// `guard.clear_ready_matching(Ready::READABLE)`.
/// Also clearing the write readiness in this case would be incorrect.
/// The [`AsyncFdReadyMutGuard::clear_ready`] method clears all readiness flags.
///
Expand Down Expand Up @@ -783,7 +783,7 @@ impl<'a, Inner: AsRawFd> AsyncFdReadyGuard<'a, Inner> {
/// when a read is observed to block. Only clear the specific readiness that is observed to
/// block. For example when a read blocks when using a combined interest,
/// only clear `Ready::READABLE`.
pub fn clear_ready_exact(&mut self, ready: Ready) {
pub fn clear_ready_matching(&mut self, ready: Ready) {
if let Some(mut event) = self.event.take() {
self.async_fd
.registration
Expand Down Expand Up @@ -936,7 +936,7 @@ impl<'a, Inner: AsRawFd> AsyncFdReadyMutGuard<'a, Inner> {
/// when a read is observed to block. Only clear the specific readiness that is observed to
/// block. For example when a read blocks when using a combined interest,
/// only clear `Ready::READABLE`.
pub fn clear_ready_exact(&mut self, ready: Ready) {
pub fn clear_ready_matching(&mut self, ready: Ready) {
if let Some(mut event) = self.event.take() {
self.async_fd
.registration
Expand Down
12 changes: 6 additions & 6 deletions tokio/tests/io_async_fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ fn send_oob_data<S: AsRawFd>(stream: &S, data: &[u8]) -> io::Result<usize> {
}

#[tokio::test]
async fn clear_ready_exact_clears_ready() {
async fn clear_ready_matching_clears_ready() {
use tokio::io::{Interest, Ready};

let (a, mut b) = socketpair();
Expand All @@ -656,15 +656,15 @@ async fn clear_ready_exact_clears_ready() {

assert_eq!(guard.ready(), Ready::READABLE | Ready::WRITABLE);

guard.clear_ready_exact(Ready::READABLE);
guard.clear_ready_matching(Ready::READABLE);
assert_eq!(guard.ready(), Ready::WRITABLE);

guard.clear_ready_exact(Ready::WRITABLE);
guard.clear_ready_matching(Ready::WRITABLE);
assert_eq!(guard.ready(), Ready::EMPTY);
}

#[tokio::test]
async fn clear_ready_exact_clears_ready_mut() {
async fn clear_ready_matching_clears_ready_mut() {
use tokio::io::{Interest, Ready};

let (a, mut b) = socketpair();
Expand All @@ -679,9 +679,9 @@ async fn clear_ready_exact_clears_ready_mut() {

assert_eq!(guard.ready(), Ready::READABLE | Ready::WRITABLE);

guard.clear_ready_exact(Ready::READABLE);
guard.clear_ready_matching(Ready::READABLE);
assert_eq!(guard.ready(), Ready::WRITABLE);

guard.clear_ready_exact(Ready::WRITABLE);
guard.clear_ready_matching(Ready::WRITABLE);
assert_eq!(guard.ready(), Ready::EMPTY);
}

0 comments on commit 3cec780

Please sign in to comment.