-
Notifications
You must be signed in to change notification settings - Fork 284
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
update to Tokio 0.3 #476
update to Tokio 0.3 #476
Changes from 9 commits
6f22d61
e970668
6c7b5bc
f4e6e2e
2c73235
4bf1153
50c44f2
5200b9a
28fe32e
2756737
2ad8bce
3921c5c
60dafdf
75fc940
ff456fb
d371ae1
d48c970
d54a8e1
ff3dc34
0cddf0f
fd60d1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ use std::{ | |
pin::Pin, | ||
task::{Context, Poll}, | ||
}; | ||
use tokio::sync::mpsc; | ||
use tokio::{stream::Stream, sync::mpsc}; | ||
use tower_service::Service; | ||
|
||
/// Task that handles processing the buffer. This type should not be used | ||
|
@@ -28,7 +28,7 @@ where | |
T::Error: Into<crate::BoxError>, | ||
{ | ||
current_message: Option<Message<Request, T::Future>>, | ||
rx: mpsc::Receiver<Message<Request, T::Future>>, | ||
rx: mpsc::UnboundedReceiver<Message<Request, T::Future>>, | ||
service: T, | ||
finish: bool, | ||
failed: Option<ServiceError>, | ||
|
@@ -48,7 +48,7 @@ where | |
{ | ||
pub(crate) fn new( | ||
service: T, | ||
rx: mpsc::Receiver<Message<Request, T::Future>>, | ||
rx: mpsc::UnboundedReceiver<Message<Request, T::Future>>, | ||
) -> (Handle, Worker<T, Request>) { | ||
let handle = Handle { | ||
inner: Arc::new(Mutex::new(None)), | ||
|
@@ -80,11 +80,11 @@ where | |
} | ||
|
||
tracing::trace!("worker polling for next message"); | ||
if let Some(mut msg) = self.current_message.take() { | ||
// poll_closed returns Poll::Ready is the receiver is dropped. | ||
// Returning Pending means it is still alive, so we should still | ||
// use it. | ||
if msg.tx.poll_closed(cx).is_pending() { | ||
if let Some(msg) = self.current_message.take() { | ||
// If the oneshot sender is closed, then the receiver is dropped, | ||
// and nobody cares about the response. If this is the case, we | ||
// should continue to the next request. | ||
if !msg.tx.is_closed() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. n.b. that |
||
tracing::trace!("resuming buffered request"); | ||
return Poll::Ready(Some((msg, false))); | ||
} | ||
|
@@ -93,8 +93,8 @@ where | |
} | ||
|
||
// Get the next request | ||
while let Some(mut msg) = ready!(Pin::new(&mut self.rx).poll_recv(cx)) { | ||
if msg.tx.poll_closed(cx).is_pending() { | ||
while let Some(msg) = ready!(Pin::new(&mut self.rx).poll_next(cx)) { | ||
if !msg.tx.is_closed() { | ||
tracing::trace!("processing new request"); | ||
return Poll::Ready(Some((msg, true))); | ||
} | ||
|
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 had issues with this test previously, but also by the looks of these tracing statements you did too? Probably should remove these :)
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.
oh whoops, didn't mean to leave those in!