-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
add Interest::PRIORITY and ready and ready_mut functions to AsyncFd #5566
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
Merged
Merged
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
b8f1d0d
stream: add `StreamNotifyClose` (#4851)
aviramha f0ddd93
add a test awaiting priority
folkertdev 3fcc4ef
add target cfg for docs
folkertdev 9780946
on CI, AsRawFd is not yet in std::os::fs
folkertdev 8d33a34
more conditional compilation
folkertdev 5fdb52f
actually read out-of-band data in test
folkertdev 024f16e
rename priority -> priority_ready
folkertdev fd24209
keep original interest for PollEvented::new
folkertdev 735dd9f
add READ_CLOSED to the priority readiness
folkertdev 3ea6402
add special waker for priority events
folkertdev 69c01cf
keep old behavior for AsyncFd::new
folkertdev 07fea45
add `AsyncFd::ready` instead of `AsyncFd::priority_ready`
folkertdev 4a254e9
remove a test that does not work
folkertdev 720d8fc
fix doc comment
folkertdev b0d1131
remove now-unused priority waker
folkertdev 2700d7f
allow fine-grained clearing of readiness on AsyncFd
folkertdev 462c926
document clearing of readiness on the ready functions
folkertdev 920e1fb
rename is_priority_ready -> is_priority
folkertdev c3de66e
de-duplicate code in the Debug instance
folkertdev 034bd78
clear the event if all readiness flags are cleared
folkertdev 4633bca
add test that readiness is actually cleared
folkertdev 395fe37
rename clear_ready_exact -> clear_ready_matching
folkertdev 81cb2bb
replicate the tcp combined interest example
folkertdev 6837709
Merge branch 'master' into priority-interest
carllerche ab05c9f
Update tokio/Cargo.toml
carllerche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,8 @@ const READABLE: usize = 0b0_01; | |
| const WRITABLE: usize = 0b0_10; | ||
| const READ_CLOSED: usize = 0b0_0100; | ||
| const WRITE_CLOSED: usize = 0b0_1000; | ||
| #[cfg(any(target_os = "linux", target_os = "android"))] | ||
| const PRIORITY: usize = 0b1_0000; | ||
|
|
||
| /// Describes the readiness state of an I/O resources. | ||
| /// | ||
|
|
@@ -31,7 +33,17 @@ impl Ready { | |
| /// Returns a `Ready` representing write closed readiness. | ||
| pub const WRITE_CLOSED: Ready = Ready(WRITE_CLOSED); | ||
|
|
||
| /// Returns a `Ready` representing priority readiness. | ||
| #[cfg(any(target_os = "linux", target_os = "android"))] | ||
| #[cfg_attr(docsrs, doc(cfg(any(target_os = "linux", target_os = "android"))))] | ||
| pub const PRIORITY: Ready = Ready(PRIORITY); | ||
|
|
||
| /// Returns a `Ready` representing readiness for all operations. | ||
| #[cfg(any(target_os = "linux", target_os = "android"))] | ||
| pub const ALL: Ready = Ready(READABLE | WRITABLE | READ_CLOSED | WRITE_CLOSED | PRIORITY); | ||
|
|
||
| /// Returns a `Ready` representing readiness for all operations. | ||
| #[cfg(not(any(target_os = "linux", target_os = "android")))] | ||
| pub const ALL: Ready = Ready(READABLE | WRITABLE | READ_CLOSED | WRITE_CLOSED); | ||
|
|
||
| // Must remain crate-private to avoid adding a public dependency on Mio. | ||
|
|
@@ -65,6 +77,13 @@ impl Ready { | |
| ready |= Ready::WRITE_CLOSED; | ||
| } | ||
|
|
||
| #[cfg(any(target_os = "linux", target_os = "android"))] | ||
| { | ||
| if event.is_priority() { | ||
| ready |= Ready::PRIORITY; | ||
| } | ||
| } | ||
|
|
||
| ready | ||
| } | ||
|
|
||
|
|
@@ -144,6 +163,23 @@ impl Ready { | |
| self.contains(Ready::WRITE_CLOSED) | ||
| } | ||
|
|
||
| /// Returns `true` if the value includes priority `readiness`. | ||
| /// | ||
| /// # Examples | ||
| /// | ||
| /// ``` | ||
| /// use tokio::io::Ready; | ||
| /// | ||
| /// assert!(!Ready::EMPTY.is_priority()); | ||
| /// assert!(!Ready::WRITABLE.is_priority()); | ||
| /// assert!(Ready::PRIORITY.is_priority()); | ||
| /// ``` | ||
| #[cfg(any(target_os = "linux", target_os = "android"))] | ||
| #[cfg_attr(docsrs, doc(cfg(any(target_os = "linux", target_os = "android"))))] | ||
| pub fn is_priority(self) -> bool { | ||
| self.contains(Ready::PRIORITY) | ||
| } | ||
|
|
||
| /// Returns true if `self` is a superset of `other`. | ||
| /// | ||
| /// `other` may represent more than one readiness operations, in which case | ||
|
|
@@ -191,6 +227,12 @@ cfg_io_readiness! { | |
| ready |= Ready::WRITE_CLOSED; | ||
| } | ||
|
|
||
| #[cfg(any(target_os = "linux", target_os = "android"))] | ||
| if interest.is_priority() { | ||
| ready |= Ready::PRIORITY; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note for the future: if we add the |
||
| ready |= Ready::READ_CLOSED; | ||
| } | ||
|
|
||
| ready | ||
| } | ||
|
|
||
|
|
@@ -240,11 +282,16 @@ impl ops::Sub<Ready> for Ready { | |
|
|
||
| impl fmt::Debug for Ready { | ||
| fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| fmt.debug_struct("Ready") | ||
| .field("is_readable", &self.is_readable()) | ||
| let mut fmt = fmt.debug_struct("Ready"); | ||
|
|
||
| fmt.field("is_readable", &self.is_readable()) | ||
| .field("is_writable", &self.is_writable()) | ||
| .field("is_read_closed", &self.is_read_closed()) | ||
| .field("is_write_closed", &self.is_write_closed()) | ||
| .finish() | ||
| .field("is_write_closed", &self.is_write_closed()); | ||
|
|
||
| #[cfg(any(target_os = "linux", target_os = "android"))] | ||
folkertdev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fmt.field("is_priority", &self.is_priority()); | ||
|
|
||
| fmt.finish() | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.