1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-06-26 19:47:43 +02:00

update deps

This commit is contained in:
Nikolay Kim
2019-01-26 13:15:17 -08:00
parent ff6ac0a67f
commit 84bd257b86
11 changed files with 45 additions and 58 deletions

View File

@ -18,10 +18,10 @@ name = "actix_utils"
path = "src/lib.rs"
[dependencies]
actix-service = "0.1.2"
actix-service = "0.1.6"
actix-codec = "0.1.0"
actix-rt = "0.1.0"
bytes = "0.4"
futures = "0.1"
tokio-timer = "0.2.8"
tokio-current-thread = "0.1"
log = "0.4"

View File

@ -1,17 +1,11 @@
//! Custom cell impl
#[cfg(feature = "cell")]
use std::cell::UnsafeCell;
#[cfg(not(feature = "cell"))]
use std::cell::{Ref, RefCell, RefMut};
use std::fmt;
use std::rc::Rc;
pub(crate) struct Cell<T> {
#[cfg(feature = "cell")]
inner: Rc<UnsafeCell<T>>,
#[cfg(not(feature = "cell"))]
inner: Rc<RefCell<T>>,
}
impl<T> Clone for Cell<T> {
@ -28,7 +22,6 @@ impl<T: fmt::Debug> fmt::Debug for Cell<T> {
}
}
#[cfg(feature = "cell")]
impl<T> Cell<T> {
pub fn new(inner: T) -> Self {
Self {
@ -36,28 +29,11 @@ impl<T> Cell<T> {
}
}
pub fn borrow(&self) -> &T {
pub fn get_ref(&self) -> &T {
unsafe { &*self.inner.as_ref().get() }
}
pub fn borrow_mut(&self) -> &mut T {
pub fn get_mut(&mut self) -> &mut T {
unsafe { &mut *self.inner.as_ref().get() }
}
}
#[cfg(not(feature = "cell"))]
impl<T> Cell<T> {
pub fn new(inner: T) -> Self {
Self {
inner: Rc::new(RefCell::new(inner)),
}
}
pub fn borrow(&self) -> Ref<T> {
self.inner.borrow()
}
pub fn borrow_mut(&self) -> RefMut<T> {
self.inner.borrow_mut()
}
}

View File

@ -42,10 +42,10 @@ where
type Future = T::Future;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
self.service.borrow_mut().poll_ready()
self.service.get_mut().poll_ready()
}
fn call(&mut self, req: Request) -> Self::Future {
self.service.borrow_mut().call(req)
self.service.get_mut().call(req)
}
}

View File

@ -3,7 +3,6 @@ use std::marker::PhantomData;
use std::mem;
use actix_codec::{AsyncRead, AsyncWrite, Decoder, Encoder, Framed};
use actix_rt::Arbiter;
use actix_service::{IntoNewService, IntoService, NewService, Service};
use futures::future::{ok, FutureResult};
use futures::unsync::mpsc;
@ -251,7 +250,7 @@ where
Ok(Async::Ready(_)) => {
if let Some(item) = self.request.take() {
let sender = self.write_tx.clone();
Arbiter::spawn(
tokio_current_thread::spawn(
self.service
.call(item)
.then(|item| sender.send(item).map(|_| ()).map_err(|_| ())),
@ -276,7 +275,7 @@ where
match self.service.poll_ready() {
Ok(Async::Ready(_)) => {
let sender = self.write_tx.clone();
Arbiter::spawn(
tokio_current_thread::spawn(
self.service
.call(item)
.then(|item| sender.send(item).map(|_| ()).map_err(|_| ())),

View File

@ -1,7 +1,6 @@
use std::marker::PhantomData;
use std::rc::Rc;
use actix_rt::spawn;
use actix_service::{IntoNewService, IntoService, NewService, Service};
use futures::future::{ok, Future, FutureResult};
use futures::unsync::mpsc;
@ -162,11 +161,13 @@ where
loop {
match self.service.poll_ready()? {
Async::Ready(_) => match self.stream.poll() {
Ok(Async::Ready(Some(item))) => spawn(StreamDispatcherService {
fut: self.service.call(Ok(item)),
stop: self.err_tx.clone(),
}),
Err(err) => spawn(StreamDispatcherService {
Ok(Async::Ready(Some(item))) => {
tokio_current_thread::spawn(StreamDispatcherService {
fut: self.service.call(Ok(item)),
stop: self.err_tx.clone(),
})
}
Err(err) => tokio_current_thread::spawn(StreamDispatcherService {
fut: self.service.call(Err(err)),
stop: self.err_tx.clone(),
}),