-
Notifications
You must be signed in to change notification settings - Fork 48
Add blocking functionality to channels #47
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
I would prefer not to provide public
I agree with your decision here not to implement FYI, one of the ways to handle such cases is to provides a wrapper type like BlockingReceiver that implements Iterator and a method to convert it from Receiver explicitly. That said, I don't see the need to provide it until someone actually needs it. |
Are there any blockers (no pun intended) for merging this? |
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 feel that the trait-based solution is a bit overkill, but I'm not sure if there are other good alternatives.
So I think this is ready to merge, aside from a nit.
Co-authored-by: Taiki Endo <[email protected]>
The nit is fixed now, want me to squash it? |
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.
Thanks!
Published in v1.7.0. |
As per discussion in smol-rs/async-lock#25, I have added
send_blocking
andrecv_blocking
methods to theSender
andReceiver
structures, respectively. In order to reduce code duplication, I implemented this by parameterizing the logic found in theSend
andRecv
futures using a trait that eitherpoll
s theEventListener
or callswait
on it.Various things I left up in the air:
wait()
methods onSend
andRecv
that use the blocking strategy to poll the future to completion. Should these be public?Recv
currently implementsStream
. It could also implementIterator
using a similar strategy to how I implemented blocking for the main methods. I decided against it, sinceStreamExt
andIterator
share many method names which could be confused. Is there an idiomatic way of going about this?Closes #21