-
Notifications
You must be signed in to change notification settings - Fork 674
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
PollFd utility functions #1877
Merged
bors
merged 1 commit into
nix-rust:master
from
JonathanWoollett-Light:pollfd-util-functions
Nov 29, 2022
Merged
PollFd utility functions #1877
bors
merged 1 commit into
nix-rust:master
from
JonathanWoollett-Light:pollfd-util-functions
Nov 29, 2022
Conversation
This file contains 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
JonathanWoollett-Light
force-pushed
the
pollfd-util-functions
branch
3 times, most recently
from
November 21, 2022 01:59
f1df78e
to
18ad17a
Compare
asomers
approved these changes
Nov 29, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors r+
Merge conflict. |
JonathanWoollett-Light
force-pushed
the
pollfd-util-functions
branch
from
November 29, 2022 01:41
18ad17a
to
92dd754
Compare
bors retry |
bors bot
added a commit
that referenced
this pull request
Nov 29, 2022
1877: PollFd utility functions r=asomers a=JonathanWoollett-Light Adds `poll::PollFd::any()` and `poll::PollFd::all()` functions which returns if any/all of the events of interest occurred in the last call to `poll` or `ppoll`. Consider the case: ```rust let (first_fd, second_fd) = /* ... */; let mut poll_fds = [ poll::PollFd::new(interrupt_fd, poll::PollFlags::POLLIN), poll::PollFd::new(transfer_fd, poll::PollFlags::POLLIN), ]; let _ = poll::poll(&mut poll_fds, -1)?; let first = poll_fds[0].revents()? != poll::PollFlags::empty(); let second = poll_fds[1].revents()? != poll::PollFlags::empty();; if first { /* ... */ } if second { /* ... */ } ``` which can now be reduced: ```rust let (first_fd, second_fd) = /* ... */; let mut poll_fds = [ poll::PollFd::new(interrupt_fd, poll::PollFlags::POLLIN), poll::PollFd::new(transfer_fd, poll::PollFlags::POLLIN), ]; let _ = poll::poll(&mut poll_fds, -1)?; let first = poll_fds[0].any()?; let second = poll_fds[1].any()?; if first { /* ... */ } if second { /* ... */ } ``` Co-authored-by: Jonathan <[email protected]>
Build failed: |
That looks like a spurious failure. bors retry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds
poll::PollFd::any()
andpoll::PollFd::all()
functions which returns if any/all of the events of interest occurred in the last call topoll
orppoll
.Consider the case:
which can now be reduced: