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

migrate to tokio 0.2.2

This commit is contained in:
Nikolay Kim
2019-12-05 16:40:24 +06:00
parent d49aca9595
commit 3a858feaec
37 changed files with 281 additions and 461 deletions

View File

@ -2,6 +2,8 @@
## [1.0.0-alpha.3] - 2019-12-xx
* Migrate to `tokio=0.2.2`
* Fix oneshot
## [1.0.0-alpha.2] - 2019-12-02

View File

@ -1,6 +1,6 @@
[package]
name = "actix-utils"
version = "1.0.0-alpha.2"
version = "1.0.0-alpha.3"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix utils - various actix net related services"
keywords = ["network", "framework", "async", "futures"]
@ -19,9 +19,9 @@ path = "src/lib.rs"
[dependencies]
actix-service = "1.0.0-alpha.3"
actix-rt = "1.0.0-alpha.2"
actix-codec = "0.2.0-alpha.2"
bytes = "0.4"
actix-rt = "1.0.0-alpha.3"
actix-codec = "0.2.0-alpha.3"
bytes = "0.5.2"
either = "1.5.2"
futures = "0.3.1"
pin-project = "0.4.6"

View File

@ -3,9 +3,9 @@ use std::future::Future;
use std::marker::PhantomData;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::time::{Duration, Instant};
use std::time::Duration;
use actix_rt::time::{delay, Delay};
use actix_rt::time::{delay_until, Delay, Instant};
use actix_service::{Service, ServiceFactory};
use futures::future::{ok, Ready};
@ -81,13 +81,13 @@ where
F: Fn() -> E,
{
pub fn new(ka: Duration, time: LowResTimeService, f: F) -> Self {
let expire = time.now() + ka;
let expire = Instant::from_std(time.now() + ka);
KeepAliveService {
f,
ka,
time,
expire,
delay: delay(expire),
delay: delay_until(expire),
_t: PhantomData,
}
}
@ -105,7 +105,7 @@ where
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
match Pin::new(&mut self.delay).poll(cx) {
Poll::Ready(_) => {
let now = self.time.now();
let now = Instant::from_std(self.time.now());
if self.expire <= now {
Poll::Ready(Err((self.f)()))
} else {
@ -119,7 +119,7 @@ where
}
fn call(&mut self, req: R) -> Self::Future {
self.expire = self.time.now() + self.ka;
self.expire = Instant::from_std(self.time.now() + self.ka);
ok(req)
}
}