This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Remove wait on future in network bridge#1765
Merged
Merged
Conversation
3d70624 to
33c932f
Compare
bkchr
suggested changes
Feb 12, 2019
| fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> { | ||
| if let Some(ref mut inner) = self.inner { | ||
| return inner | ||
| .poll() |
| return inner | ||
| .poll() | ||
| } | ||
| if let Ok(futures::Async::Ready(mut inner)) = self.outer.poll() { |
Member
There was a problem hiding this comment.
If the oneshot::Receiver is returning Error(Canceled), this will stuck forever.
Contributor
Author
There was a problem hiding this comment.
How could we handle the error? An error would indicate network has shut down, and the entire system is likely shutting down. We could panic on an Err I guess...
Member
There was a problem hiding this comment.
I don't know what the error indicates. Maybe we should just throw Err(()).
Contributor
Author
There was a problem hiding this comment.
We can propagate an appropriate error.
| self.inner = Some(inner); | ||
| return poll_result | ||
| } | ||
| Ok(futures::Async::NotReady) |
Member
There was a problem hiding this comment.
Maybe rewrite this whole function as:
loop {
match self.inner {
Some(ref mut inner) => return inner.poll(),
None => match self.outer.poll() {
Ok(Ready(inner)) => self.inner = Some(inner),
Ok(NotReady) => return Ok(NotReady),
Err(e) => handle the error,
}
}
}
Contributor
Author
There was a problem hiding this comment.
clever, and I'd rather rely on the next call to poll(or actually just do it in the same call to poll without the loop).
4a18ff3 to
f8c8dd4
Compare
andresilva
approved these changes
Feb 12, 2019
bkchr
approved these changes
Feb 12, 2019
MTDK1
pushed a commit
to bdevux/substrate
that referenced
this pull request
Apr 12, 2019
* remove wait on future in network bridge * nit Co-Authored-By: gterzian <2792687+gterzian@users.noreply.github.com> * nit Co-Authored-By: gterzian <2792687+gterzian@users.noreply.github.com> * nit * propagate error * nit once more * nit Co-Authored-By: gterzian <2792687+gterzian@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow up on #1340 (comment)