-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Make Condvar::wait_timeout return an enum instead of a bool #27826
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
Conversation
/// A type indicating whether a timed wait on a condition variable returned | ||
/// due to a time out or not. | ||
#[derive(Debug, PartialEq, Eq)] | ||
pub enum TimedOut { |
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.
This may not be the best way of representing/naming this enum.
b5d0df3
to
c0f36ab
Compare
Perhaps this could also have a convenience boolean accessor method like |
This may also want to consider naming with respect to that as well. |
I'll add a |
Updated with the accessor. |
Hm, so cc @aturon, thoughts on this return value? |
@alexcrichton updated |
/// A type indicating whether a timed wait on a condition variable returned | ||
/// due to a time out or not. | ||
#[derive(Debug, PartialEq, Eq, Copy, Clone)] | ||
#[unstable(feature = "wait_timeout", reason = "newly added")] |
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.
This'll need an explicit issue
tag, and could you also add the unstable tag to the timed_out
method?
r=me with a nit, thanks @sfackler! |
Returning a primitive bool results in a somewhat confusing API - does `true` indicate success - i.e. no timeout, or that a timeout has occurred? An explicitly named enum makes it clearer. [breaking-change]
a1b136e
to
12216b7
Compare
@bors r=alexcrichton |
📌 Commit 12216b7 has been approved by |
⌛ Testing commit 12216b7 with merge 8951c00... |
💔 Test failed - auto-linux-32-opt |
@bors: retry |
⌛ Testing commit 12216b7 with merge b5f22dc... |
@bors: retry force |
Returning a primitive bool results in a somewhat confusing API - does `true` indicate success - i.e. no timeout, or that a timeout has occurred? An explicitly named enum makes it clearer. [breaking-change] r? @alexcrichton
Returning a primitive bool results in a somewhat confusing API - does
true
indicate success - i.e. no timeout, or that a timeout hasoccurred? An explicitly named enum makes it clearer.
[breaking-change]
r? @alexcrichton