chore(dependencies): update pin-project to 0.4

This commit is contained in:
Taiki Endo
2019-09-27 05:14:13 +09:00
committed by Sean McArthur
parent d40978ce08
commit bcb66736fb
6 changed files with 46 additions and 29 deletions

View File

@@ -32,7 +32,7 @@ iovec = "0.1"
itoa = "0.4.1"
log = "0.4"
net2 = { version = "0.2.32", optional = true }
pin-project = { version = "=0.4.0-alpha.11", features = ["project_attr"] }
pin-project = "0.4"
time = "0.1"
tokio = { version = "=0.2.0-alpha.5", optional = true, default-features = false, features = ["rt-full"] }
tower-service = "=0.3.0-alpha.1"
@@ -193,3 +193,18 @@ required-features = ["runtime", "unstable-stream"]
name = "server"
path = "tests/server.rs"
required-features = ["runtime", "unstable-stream"]
[patch.crates-io]
tokio = { git = "https://github.com/tokio-rs/tokio" }
tokio-codec = { git = "https://github.com/tokio-rs/tokio" }
tokio-executor = { git = "https://github.com/tokio-rs/tokio" }
tokio-fs = { git = "https://github.com/tokio-rs/tokio" }
tokio-io = { git = "https://github.com/tokio-rs/tokio" }
tokio-macros = { git = "https://github.com/tokio-rs/tokio" }
tokio-net = { git = "https://github.com/tokio-rs/tokio" }
tokio-sync = { git = "https://github.com/tokio-rs/tokio" }
tokio-test = { git = "https://github.com/tokio-rs/tokio" }
tokio-timer = { git = "https://github.com/tokio-rs/tokio" }
tower-service = { git = "https://github.com/taiki-e/tower", branch = "pin-project" }
tower-make = { git = "https://github.com/taiki-e/tower", branch = "pin-project" }

View File

@@ -98,9 +98,9 @@ where
{
type Output = F::Output;
fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
let mut me = self.project();
loop {
let me = self.project();
match mem::replace(me.state, State::Draining) {
State::Watch(on_drain) => {
let recv = me.watch.rx.recv_ref();
@@ -109,7 +109,7 @@ where
match recv.poll_unpin(cx) {
Poll::Ready(None) => {
// Drain has been triggered!
on_drain(me.future);
on_drain(me.future.as_mut());
},
Poll::Ready(Some(_/*State::Open*/)) |
Poll::Pending => {

View File

@@ -254,11 +254,11 @@ where
E: Into<Box<dyn StdError + Send + Sync>>,
{
#[project]
fn poll2(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<crate::Result<()>> {
fn poll2(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<crate::Result<()>> {
let mut me = self.project();
loop {
let mut me = self.project();
#[project]
let next = match me.state.project() {
let next = match me.state.as_mut().project() {
H2StreamState::Service(h) => {
let res = match h.poll(cx) {
Poll::Ready(Ok(r)) => r,

View File

@@ -509,7 +509,7 @@ where
///
/// This `Connection` should continue to be polled until shutdown
/// can finish.
pub fn graceful_shutdown(mut self: Pin<&mut Self>) {
pub fn graceful_shutdown(self: Pin<&mut Self>) {
match self.project().conn.as_mut().unwrap() {
Either::A(ref mut h1) => {
h1.disable_keep_alive();
@@ -727,8 +727,9 @@ where
B: Payload,
E: H2Exec<<S::Service as Service<Body>>::Future, B>,
{
fn poll_next_(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Option<crate::Result<Connecting<IO, S::Future, E>>>> {
match ready!(self.project().make_service.poll_ready_ref(cx)) {
fn poll_next_(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Option<crate::Result<Connecting<IO, S::Future, E>>>> {
let me = self.project();
match ready!(me.make_service.poll_ready_ref(cx)) {
Ok(()) => (),
Err(e) => {
trace!("make_service closed");
@@ -736,13 +737,13 @@ where
}
}
if let Some(item) = ready!(self.project().incoming.poll_accept(cx)) {
if let Some(item) = ready!(me.incoming.poll_accept(cx)) {
let io = item.map_err(crate::Error::new_accept)?;
let new_fut = self.project().make_service.make_service_ref(&io);
let new_fut = me.make_service.make_service_ref(&io);
Poll::Ready(Some(Ok(Connecting {
future: new_fut,
io: Some(io),
protocol: self.protocol.clone(),
protocol: me.protocol.clone(),
})))
} else {
Poll::Ready(None)
@@ -781,10 +782,11 @@ where
{
type Output = Result<Connection<I, S, E>, FE>;
fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
let service = ready!(self.project().future.poll(cx))?;
let io = self.project().io.take().expect("polled after complete");
Poll::Ready(Ok(self.protocol.serve_connection(io, service)))
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
let me = self.project();
let service = ready!(me.future.poll(cx))?;
let io = me.io.take().expect("polled after complete");
Poll::Ready(Ok(me.protocol.serve_connection(io, service)))
}
}
@@ -816,15 +818,16 @@ where
B: Payload,
E: H2Exec<<S::Service as Service<Body>>::Future, B>,
{
pub(super) fn poll_watch<W>(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>, watcher: &W) -> Poll<crate::Result<()>>
pub(super) fn poll_watch<W>(self: Pin<&mut Self>, cx: &mut task::Context<'_>, watcher: &W) -> Poll<crate::Result<()>>
where
E: NewSvcExec<IO, S::Future, S::Service, E, W>,
W: Watcher<IO, S::Service, E>,
{
let mut me = self.project();
loop {
if let Some(connecting) = ready!(self.project().serve.poll_next_(cx)?) {
if let Some(connecting) = ready!(me.serve.as_mut().poll_next_(cx)?) {
let fut = NewSvcTask::new(connecting, watcher.clone());
self.project().serve.project().protocol.exec.execute_new_svc(fut)?;
me.serve.as_mut().project().protocol.exec.execute_new_svc(fut)?;
} else {
return Poll::Ready(Ok(()));
}
@@ -841,8 +844,7 @@ where
type Output = A::Output;
#[project]
fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
// Just simple pin projection to the inner variants
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
#[project]
match self.project() {
Either::A(a) => a.poll(cx),
@@ -939,16 +941,16 @@ pub(crate) mod spawn_all {
type Output = ();
#[project]
fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
// If it weren't for needing to name this type so the `Send` bounds
// could be projected to the `Serve` executor, this could just be
// an `async fn`, and much safer. Woe is me.
let mut me = self.project();
loop {
let mut me = self.project();
let next = {
#[project]
match me.state.project() {
match me.state.as_mut().project() {
State::Connecting(connecting, watcher) => {
let res = ready!(connecting.poll(cx));
let conn = match res {
@@ -963,7 +965,7 @@ pub(crate) mod spawn_all {
State::Connected(connected)
},
State::Connected(future) => {
return future
return future
.poll(cx)
.map(|res| {
if let Err(err) = res {

View File

@@ -214,7 +214,7 @@ where
{
type Output = crate::Result<()>;
fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
self.project().spawn_all.poll_watch(cx, &NoopWatcher)
}
}

View File

@@ -61,12 +61,12 @@ where
type Output = crate::Result<()>;
#[project]
fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
let mut me = self.project();
loop {
let next = {
#[project]
match me.state.project() {
match me.state.as_mut().project() {
State::Running {
drain,
spawn_all,