From c1cdc9908a4e9e4732f26e7be2c4594ff718f7e5 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Fri, 15 Nov 2019 16:06:44 +0600 Subject: [PATCH] update deps and fix definitions --- actix-codec/src/framed.rs | 20 ++++++++++++-------- actix-codec/src/lib.rs | 1 - actix-server-config/Cargo.toml | 3 ++- actix-server-config/src/lib.rs | 10 ++++++---- actix-threadpool/src/lib.rs | 20 +++++++------------- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/actix-codec/src/framed.rs b/actix-codec/src/framed.rs index 7152b459..29892f93 100644 --- a/actix-codec/src/framed.rs +++ b/actix-codec/src/framed.rs @@ -61,14 +61,6 @@ where inner: framed_read2(framed_write2(Fuse(inner, codec), lw, hw)), } } - - /// Force send item - pub fn force_send( - &mut self, - item: ::Item, - ) -> Result<(), ::Error> { - self.inner.get_mut().force_send(item) - } } impl Framed { @@ -224,6 +216,18 @@ impl Framed { } impl Framed { + /// Force send item + pub fn force_send( + &mut self, + item: ::Item, + ) -> Result<(), ::Error> + where + T: AsyncWrite + Unpin, + U: Encoder + Unpin, + { + self.inner.get_mut().force_send(item) + } + pub fn next_item(&mut self, cx: &mut Context<'_>) -> Poll>> where T: AsyncRead + Unpin, diff --git a/actix-codec/src/lib.rs b/actix-codec/src/lib.rs index 06c66112..77102a8c 100644 --- a/actix-codec/src/lib.rs +++ b/actix-codec/src/lib.rs @@ -21,5 +21,4 @@ pub use self::framed_read::FramedRead; pub use self::framed_write::FramedWrite; pub use tokio_codec::{Decoder, Encoder}; -// TODO: Migrate to futures asyncRead pub use tokio_io::{AsyncRead, AsyncWrite}; diff --git a/actix-server-config/Cargo.toml b/actix-server-config/Cargo.toml index 5a53fbb9..7f7cf23f 100644 --- a/actix-server-config/Cargo.toml +++ b/actix-server-config/Cargo.toml @@ -22,6 +22,7 @@ openssl = ["tokio-openssl"] rustls = ["tokio-rustls"] [dependencies] -tokio = "0.2.0-alpha.6" +tokio-io = "0.2.0-alpha.6" +tokio-net = "0.2.0-alpha.6" tokio-openssl = { version = "0.4.0-alpha.6", optional = true } tokio-rustls = { version = "0.12.0-alpha.8", optional = true } diff --git a/actix-server-config/src/lib.rs b/actix-server-config/src/lib.rs index 2ffb735f..d3b7ab4e 100644 --- a/actix-server-config/src/lib.rs +++ b/actix-server-config/src/lib.rs @@ -5,8 +5,8 @@ use std::net::SocketAddr; use std::rc::Rc; use std::{fmt, io, net, ops, time}; -use tokio::io::{AsyncRead, AsyncWrite}; -use tokio::net::TcpStream; +use tokio_io::{AsyncRead, AsyncWrite}; +use tokio_net::tcp::TcpStream; #[derive(Debug, Clone)] pub struct ServerConfig { @@ -62,6 +62,8 @@ pub struct Io { params: P, } +impl Unpin for Io {} + impl Io { pub fn new(io: T) -> Self { Self { @@ -141,7 +143,7 @@ impl fmt::Debug for Io { } /// Low-level io stream operations -pub trait IoStream: AsyncRead + AsyncWrite { +pub trait IoStream: AsyncRead + AsyncWrite + Unpin { /// Returns the socket address of the remote peer of this TCP connection. fn peer_addr(&self) -> Option { None @@ -224,7 +226,7 @@ impl IoStream for tokio_rustls::server::TlsStream { } #[cfg(unix)] -impl IoStream for tokio::net::UnixStream { +impl IoStream for tokio_net::uds::UnixStream { #[inline] fn peer_addr(&self) -> Option { None diff --git a/actix-threadpool/src/lib.rs b/actix-threadpool/src/lib.rs index 5ed6b7ca..62a34abe 100644 --- a/actix-threadpool/src/lib.rs +++ b/actix-threadpool/src/lib.rs @@ -1,16 +1,15 @@ //! Thread pool for blocking operations -use std::{ - future::Future, - pin::Pin, - task::{Context, Poll}, -}; +use std::future::Future; +use std::pin::Pin; +use std::task::{Context, Poll}; -use derive_more::Display; use futures::channel::oneshot; use parking_lot::Mutex; use threadpool::ThreadPool; +pub use futures::channel::oneshot::Canceled; + /// Env variable for default cpu pool size. const ENV_CPU_POOL_VAR: &str = "ACTIX_THREADPOOL"; @@ -40,11 +39,6 @@ thread_local! { }; } -/// Error of blocking operation execution being cancelled. -#[derive(Clone, Copy, Debug, Display)] -#[display(fmt = "Thread pool is gone")] -pub struct Cancelled; - /// Execute blocking function on a thread pool, returns future that resolves /// to result of the function execution. pub fn run(f: F) -> CpuFuture @@ -71,11 +65,11 @@ pub struct CpuFuture { } impl Future for CpuFuture { - type Output = Result; + type Output = Result; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let rx = Pin::new(&mut Pin::get_mut(self).rx); let res = futures::ready!(rx.poll(cx)); - Poll::Ready(res.map_err(|_| Cancelled)) + Poll::Ready(res.map_err(|_| Canceled)) } }