From 8bb81c07688683a2dbd1fb1ff993568f9de1d333 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 11 Dec 2019 18:55:53 +0600 Subject: [PATCH] optimize InOrder service --- actix-utils/CHANGES.md | 4 ++++ actix-utils/Cargo.toml | 2 +- actix-utils/src/order.rs | 9 --------- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/actix-utils/CHANGES.md b/actix-utils/CHANGES.md index 0aece6c4..ee8fc50b 100644 --- a/actix-utils/CHANGES.md +++ b/actix-utils/CHANGES.md @@ -1,5 +1,9 @@ # Changes +## [1.0.1] - 2019-12-11 + +* Optimize InOrder service + ## [1.0.0] - 2019-12-11 * Simplify oneshot and mpsc implementations diff --git a/actix-utils/Cargo.toml b/actix-utils/Cargo.toml index 7cf69bef..9539733e 100644 --- a/actix-utils/Cargo.toml +++ b/actix-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-utils" -version = "1.0.0" +version = "1.0.1" authors = ["Nikolay Kim "] description = "Actix utils - various actix net related services" keywords = ["network", "framework", "async", "futures"] diff --git a/actix-utils/src/order.rs b/actix-utils/src/order.rs index a82cf2c7..a5a6cc1f 100644 --- a/actix-utils/src/order.rs +++ b/actix-utils/src/order.rs @@ -4,14 +4,12 @@ use std::fmt; use std::future::Future; use std::marker::PhantomData; use std::pin::Pin; -use std::rc::Rc; use std::task::{Context, Poll}; use actix_service::{IntoService, Service, Transform}; use futures::future::{ok, Ready}; use crate::oneshot; -use crate::task::LocalWaker; struct Record { rx: oneshot::Receiver>, @@ -105,7 +103,6 @@ where pub struct InOrderService { service: S, - task: Rc, acks: VecDeque>, } @@ -123,7 +120,6 @@ where Self { service: service.into_service(), acks: VecDeque::new(), - task: Rc::new(LocalWaker::new()), } } } @@ -141,9 +137,6 @@ where type Future = InOrderServiceResponse; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { - // poll_ready could be called from different task - self.task.register(cx.waker()); - // check acks while !self.acks.is_empty() { let rec = self.acks.front_mut().unwrap(); @@ -172,11 +165,9 @@ where let (tx2, rx2) = oneshot::channel(); self.acks.push_back(Record { rx: rx1, tx: tx2 }); - let task = self.task.clone(); let fut = self.service.call(request); actix_rt::spawn(async move { let res = fut.await; - task.wake(); let _ = tx1.send(res); });