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

Added readiness and interest for interrupt #210

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/loop_logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,7 @@ mod tests {
Readiness {
readable: true,
writable: false,
interrupted: false,
error: false,
},
token,
Expand Down
23 changes: 22 additions & 1 deletion src/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,45 @@ pub struct Interest {

/// Wait for the FD to be writable
pub writable: bool,

/// Wait for the FD to be interrupted
pub interrupted: bool,
}

impl Interest {
/// Shorthand for empty interest
pub const EMPTY: Interest = Interest {
readable: false,
writable: false,
interrupted: false,
};

/// Shorthand for read interest
pub const READ: Interest = Interest {
readable: true,
writable: false,
interrupted: false,
};

/// Shorthand for write interest
pub const WRITE: Interest = Interest {
readable: false,
writable: true,
interrupted: false,
};

/// Shorthand for interrupt interest
pub const INTERRUPT: Interest = Interest {
readable: false,
writable: false,
interrupted: true,
};

/// Shorthand for read and write interest
pub const BOTH: Interest = Interest {
pub const ALL: Interest = Interest {
readable: true,
writable: true,
interrupted: true,
};
}

Expand All @@ -93,6 +107,9 @@ pub struct Readiness {
/// Is the FD writable
pub writable: bool,

/// Is the FD interrupted
pub interrupted: bool,

/// Is the FD in an error state
pub error: bool,
}
Expand All @@ -102,6 +119,7 @@ impl Readiness {
pub const EMPTY: Readiness = Readiness {
readable: false,
writable: false,
interrupted: false,
error: false,
};
}
Expand Down Expand Up @@ -252,6 +270,7 @@ impl Poll {
readiness: Readiness {
readable: ev.readable,
writable: ev.writable,
interrupted: ev.is_interrupt(),
error: false,
},
token: Token {
Expand All @@ -271,6 +290,7 @@ impl Poll {
readiness: Readiness {
readable: true,
writable: false,
interrupted: false,
error: false,
},
token,
Expand Down Expand Up @@ -431,6 +451,7 @@ fn cvt_interest(interest: Interest, tok: Token) -> Event {
let mut event = Event::none(tok.inner.into());
event.readable = interest.readable;
event.writable = interest.writable;
event.set_interrupt(interest.interrupted);
event
}

Expand Down