Skip to content

Commit e53b92a

Browse files
authored
io: clarify clear_ready docs (#6304)
1 parent 7536132 commit e53b92a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tokio/src/io/async_fd.rs

+16
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,10 @@ impl<'a, Inner: AsRawFd> AsyncFdReadyGuard<'a, Inner> {
826826
/// _actually observes_ that the file descriptor is _not_ ready. Do not call
827827
/// it simply because, for example, a read succeeded; it should be called
828828
/// when a read is observed to block.
829+
///
830+
/// This method only clears readiness events that happened before the creation of this guard.
831+
/// In other words, if the IO resource becomes ready between the creation of the guard and
832+
/// this call to `clear_ready`, then the readiness is not actually cleared.
829833
pub fn clear_ready(&mut self) {
830834
if let Some(event) = self.event.take() {
831835
self.async_fd.registration.clear_readiness(event);
@@ -846,6 +850,10 @@ impl<'a, Inner: AsRawFd> AsyncFdReadyGuard<'a, Inner> {
846850
/// block. For example when a read blocks when using a combined interest,
847851
/// only clear `Ready::READABLE`.
848852
///
853+
/// This method only clears readiness events that happened before the creation of this guard.
854+
/// In other words, if the IO resource becomes ready between the creation of the guard and
855+
/// this call to `clear_ready`, then the readiness is not actually cleared.
856+
///
849857
/// # Examples
850858
///
851859
/// Concurrently read and write to a [`std::net::TcpStream`] on the same task without
@@ -1042,6 +1050,10 @@ impl<'a, Inner: AsRawFd> AsyncFdReadyMutGuard<'a, Inner> {
10421050
/// _actually observes_ that the file descriptor is _not_ ready. Do not call
10431051
/// it simply because, for example, a read succeeded; it should be called
10441052
/// when a read is observed to block.
1053+
///
1054+
/// This method only clears readiness events that happened before the creation of this guard.
1055+
/// In other words, if the IO resource becomes ready between the creation of the guard and
1056+
/// this call to `clear_ready`, then the readiness is not actually cleared.
10451057
pub fn clear_ready(&mut self) {
10461058
if let Some(event) = self.event.take() {
10471059
self.async_fd.registration.clear_readiness(event);
@@ -1062,6 +1074,10 @@ impl<'a, Inner: AsRawFd> AsyncFdReadyMutGuard<'a, Inner> {
10621074
/// block. For example when a read blocks when using a combined interest,
10631075
/// only clear `Ready::READABLE`.
10641076
///
1077+
/// This method only clears readiness events that happened before the creation of this guard.
1078+
/// In other words, if the IO resource becomes ready between the creation of the guard and
1079+
/// this call to `clear_ready`, then the readiness is not actually cleared.
1080+
///
10651081
/// # Examples
10661082
///
10671083
/// Concurrently read and write to a [`std::net::TcpStream`] on the same task without

0 commit comments

Comments
 (0)