-
Notifications
You must be signed in to change notification settings - Fork 647
Add new_count_waker #1402
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add new_count_waker #1402
Conversation
Some more notes: The atomic ordering might be overkill, but since it's a test API I don't think the performance impact matters too much. Also I didn't add a test, but the example tests the entire API already. |
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.
LGTM, we should settle on just a single API before 0.3 is released, but having both for now seems fine to me.
I think the Travis failure is unrelated, from the log:
Other architectures are fine. |
Yeah, it’s #1396, I would fix it but I don’t really know if there’s a way to do so that doesn’t break other stuff. |
This is an alternative API to WakeCounter. Closes #1384.
I've force pushed a rebase on master, the CI should pass now as the failure was fixed in #1407. |
Seems good to me! I'd prefer we replaced the old one at the same time, though, or at least marked it as deprecated and switched our internal usage. No reason to let tech debt sit around on an alpha version of the library. |
inner: Arc<WakerInner>, | ||
} | ||
|
||
impl PartialEq<usize> for AwokenCount { |
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.
I think Deref<Target = usize>
would also be handy.
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.
How can I do that? I don't think AtomicUsize
has any methods that allow you to get a reference to the inner usize. I tried the following
impl Deref for AwokenCount {
type Target = usize;
fn deref(&self) -> &usize {
&self.inner.count.load(Ordering::SeqCst)
}
}
But that gives the cannot return reference to temporary value
error, which makes sense.
I could add back the get(&self) -> usize
method
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.
ah, yeah, you're right-- get
would be great.
@cramertj I'm going to address the comments now, to respond to your comment in the other issue. |
sg, thanks! |
It's replace by new_count_waker.
Pushed 2 commits to changes the tests and remove the old |
Yeah, |
@cramertj I think the test will pass (they work on my machine ™), if your OK with the API then I'm going to bed now. |
Yup, looks good, thanks for the changes! |
This is an alternative API to WakeCounter, see #1384.
I didn't touch the old API, but it might be a bit confusing that there are two different API's to do the same thing. I'll leave it up to someone else to decide whether to deprecate/remove/leave it.
Closes #1384.
/cc @Nemo157