Skip to content
Open
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
29 changes: 29 additions & 0 deletions litebox/src/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,29 @@ pub trait IOPollable {
/// calls are what notify observers. This particular function itself however _may_ be used to
/// essentially get "the current status" of events for the system.
fn check_io_events(&self) -> Events;

/// Returns `true` if this pollable cannot deliver asynchronous observer
/// notifications (e.g. host-backed stdin where the host has no callback
/// mechanism). Callers should use periodic polling instead of blocking
/// indefinitely on observer wakeups.
///
/// Defaults to `false` (async notifications work). This is safe for all
/// existing implementors; callers that use this method arrive in subsequent
/// stacked PRs.
fn needs_host_poll(&self) -> bool {
false
}

/// Returns `true` if reads on this pollable should block when no data is
/// available. Returns `false` for pollables whose callers perform
/// asynchronous readiness checks and expect a "would block" indication
/// immediately (e.g. PTY master side).
///
/// Defaults to `true` (blocking reads). This is safe for all existing
/// 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

}

impl<T: IOPollable> IOPollable for alloc::sync::Arc<T> {
Expand All @@ -61,4 +84,10 @@ impl<T: IOPollable> IOPollable for alloc::sync::Arc<T> {
fn check_io_events(&self) -> Events {
self.as_ref().check_io_events()
}
fn needs_host_poll(&self) -> bool {
self.as_ref().needs_host_poll()
}
fn should_block_read(&self) -> bool {
self.as_ref().should_block_read()
}
}
Loading