Skip to content

Commit

Permalink
refactor CallAll::poll_next
Browse files Browse the repository at this point in the history
  • Loading branch information
leoyvens committed Mar 29, 2022
1 parent 1772376 commit b6f403d
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions tower/src/util/call_all/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,18 @@ where
.expect("Using CallAll after extracing inner Service");
ready!(svc.poll_ready(cx))?;

// If it is, gather the next request (if there is one)
match this.stream.as_mut().poll_next(cx) {
Poll::Ready(r) => match r {
Some(req) => {
this.queue.push(svc.call(req));
}
None => {
// We're all done once any outstanding requests have completed
*this.eof = true;
}
},
Poll::Pending => {
// TODO: We probably want to "release" the slot we reserved in Svc here.
// It may be a while until we get around to actually using it.
return Poll::Pending;
// If it is, gather the next request (if there is one), or return `Pending` if the
// stream is not ready.
// TODO: We probably want to "release" the slot we reserved in Svc if the
// stream returns `Pending`. It may be a while until we get around to actually
// using it.
match ready!(this.stream.as_mut().poll_next(cx)) {
Some(req) => {
this.queue.push(svc.call(req));
}
None => {
// We're all done once any outstanding requests have completed
*this.eof = true;
}
}
}
Expand Down

0 comments on commit b6f403d

Please sign in to comment.