1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-23 22:51:07 +01:00

update deps and fix definitions

This commit is contained in:
Nikolay Kim 2019-11-15 16:06:44 +06:00
parent be7904fd57
commit c1cdc9908a
5 changed files with 27 additions and 27 deletions

View File

@ -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: <U as Encoder>::Item,
) -> Result<(), <U as Encoder>::Error> {
self.inner.get_mut().force_send(item)
}
}
impl<T, U> Framed<T, U> {
@ -224,6 +216,18 @@ impl<T, U> Framed<T, U> {
}
impl<T, U> Framed<T, U> {
/// Force send item
pub fn force_send(
&mut self,
item: <U as Encoder>::Item,
) -> Result<(), <U as Encoder>::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<Option<Result<U::Item, U::Error>>>
where
T: AsyncRead + Unpin,

View File

@ -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};

View File

@ -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 }

View File

@ -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<T, P = ()> {
params: P,
}
impl<T: Unpin> Unpin for Io<T> {}
impl<T> Io<T, ()> {
pub fn new(io: T) -> Self {
Self {
@ -141,7 +143,7 @@ impl<T: fmt::Debug, P> fmt::Debug for Io<T, P> {
}
/// 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<SocketAddr> {
None
@ -224,7 +226,7 @@ impl<T: IoStream + Unpin> IoStream for tokio_rustls::server::TlsStream<T> {
}
#[cfg(unix)]
impl IoStream for tokio::net::UnixStream {
impl IoStream for tokio_net::uds::UnixStream {
#[inline]
fn peer_addr(&self) -> Option<net::SocketAddr> {
None

View File

@ -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, I>(f: F) -> CpuFuture<I>
@ -71,11 +65,11 @@ pub struct CpuFuture<I> {
}
impl<I> Future for CpuFuture<I> {
type Output = Result<I, Cancelled>;
type Output = Result<I, Canceled>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
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))
}
}