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
sync: add notify
method to Receiver
from watch
module
#2490
Conversation
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.
We should consider if Option<()>
is the best return value here. Additionally, as I mentioned in #2404, I'm not convinced that notify
is the best name for the function.
Co-authored-by: Alice Ryhl <alice@ryhl.io>
Huh, apparently it doesn't compile if you move the I've thought a bit more about the pub async fn recv_ref<'a>(&'a mut self) -> Option<Ref<'a, T>> {
let has_next = poll_fn(|cx| self.poll_recv_ref(cx).map(|opt| opt.is_some())).await;
if has_next {
Some(self.borrow())
} else {
None
}
} This seems like a better approach than simply waiting. |
/// assert!(v.is_none()); | ||
/// } | ||
/// ``` | ||
pub async fn notify(&mut self) -> Option<()> { |
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.
We probably want to name this notified
to match closed
.
Then, it would be used as: rx.notified().await
.
Are you interested in getting this PR across the finish line? |
This has been done in #2814. Thanks for the proposal and getting the work started 👍 |
Motivation
Attempt to solve #2404
Solution
Modified
recv
method to return Option<()> instead of Option< T >I have added documentation test.