Skip to content

Add needs_host_poll() and should_block_read() to IOPollable#753

Open
wdcui wants to merge 1 commit intomainfrom
wdcui/pr3c-iopollable
Open

Add needs_host_poll() and should_block_read() to IOPollable#753
wdcui wants to merge 1 commit intomainfrom
wdcui/pr3c-iopollable

Conversation

@wdcui
Copy link
Copy Markdown
Member

@wdcui wdcui commented Apr 7, 2026

Summary

  • Add needs_host_poll() default method to IOPollable — returns false by default; overridden by IO objects that require the host to perform the actual poll (e.g., host-backed stdin).
  • Add should_block_read() default method to IOPollable — returns true by default; overridden by IO objects where reads should never block even when the fd is in blocking mode.
  • Add Waker::ptr_eq() utility for comparing waker identity without waking.

Split from #743.

Add two new default methods to the IOPollable trait:

- needs_host_poll(): indicates the pollable cannot deliver async observer
  notifications (e.g. host-backed stdin), so callers should poll periodically.
- should_block_read(): indicates whether reads should block when no data is
  available. Returns false for fds that use epoll/poll and expect EAGAIN.

Both default to the backward-compatible behavior (no host poll needed,
reads block). Forward the methods through the Arc<T> blanket impl.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

🤖 SemverChecks 🤖 No breaking API changes detected

Note: this does not mean API is unchanged, or even that there are no breaking changes; simply, none of the detections triggered.

@jaybosamiya-ms jaybosamiya-ms added the expmt:shadow-kiln Tag to quickly find the different PRs as part of the "shadow kiln" experiment. label Apr 11, 2026
Copy link
Copy Markdown
Member

@jaybosamiya-ms jaybosamiya-ms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the context of why these are needed, which I would expect to see in the PR description at least, it is unclear what these are adding. Neither the implementors nor the callers of this show up, so without context, this is simply increasing the interface size without clear indication of why.

Also, I am not convinced at least as is this is a good design. It is almost never the case that a boolean-returning design is the right move. In this particular case, maybe it is register_observer that should return a #[must_use] object that forces you to poll for the needs_host_poll state? I'm not even sure what the should_block_read is supposed to do here.

Importantly, without the context of the users/implementors of this interface it is not clear to me this is a good interface. And indeed since they are just boolean-returning things, they are essentially acting like config flags, which is more-often-than-not a bad interface design.

/// implementors; callers arrive in subsequent stacked PRs.
fn should_block_read(&self) -> bool {
true
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments here:

  • documentation comments should not talk about "existing implementors" and such; they are meant to be long-term objects in the codebase
  • similarly, callers and other stacked PRs should not be in the docs
  • Also see top-level comment for this review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

expmt:shadow-kiln Tag to quickly find the different PRs as part of the "shadow kiln" experiment.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants