-
Notifications
You must be signed in to change notification settings - Fork 172
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
Change poll
's timeout from c_int
to Option<&Timespec>
.
#1285
Conversation
This harmonizes the timeout with the rest of rustix, which uses `Timespec` for all time values. And, it eliminates the awkwardness of using `-1` as a sentinel value. On platforms with `ppoll`, the `Timespec` can be passed straight to the OS. On platforms without `ppoll`, we have to do a fallible conversion into `c_int`.
80fbb61
to
5be3893
Compare
Will take a look sometime this week. |
} | ||
secs.checked_mul(1000) | ||
.and_then(|millis| { | ||
millis.checked_add((i64::from(timeout.tv_nsec) + 999_999) / 1_000_000) |
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.
Can we add a comment that says the purpose of this is to round up to the nearest millisecond?
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.
Done.
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.
Sweet, this looks amazing!
This harmonizes the timeout with the rest of rustix, which uses
Timespec
for all time values. And, it eliminates the awkwardness of using-1
as a sentinel value.On platforms with
ppoll
, theTimespec
can be passed straight to the OS. On platforms withoutppoll
, we have to do a fallible conversion intoc_int
.