mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-27 23:42:56 +01:00
Release future early for .and_then() and .then() combinators
This commit is contained in:
parent
e8a1664c15
commit
61939c7af2
@ -1,5 +1,12 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [0.1.2] - 2018-12-12
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
* Release future early for `.and_then()` and `.then()` combinators
|
||||||
|
|
||||||
|
|
||||||
## [0.1.1] - 2018-12-09
|
## [0.1.1] - 2018-12-09
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-service"
|
name = "actix-service"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Actix Service"
|
description = "Actix Service"
|
||||||
keywords = ["network", "framework", "async", "futures"]
|
keywords = ["network", "framework", "async", "futures"]
|
||||||
|
@ -61,7 +61,7 @@ where
|
|||||||
{
|
{
|
||||||
b: Cell<B>,
|
b: Cell<B>,
|
||||||
fut_b: Option<B::Future>,
|
fut_b: Option<B::Future>,
|
||||||
fut_a: A::Future,
|
fut_a: Option<A::Future>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A, B, Request> AndThenFuture<A, B, Request>
|
impl<A, B, Request> AndThenFuture<A, B, Request>
|
||||||
@ -69,10 +69,10 @@ where
|
|||||||
A: Service<Request>,
|
A: Service<Request>,
|
||||||
B: Service<A::Response, Error = A::Error>,
|
B: Service<A::Response, Error = A::Error>,
|
||||||
{
|
{
|
||||||
fn new(fut_a: A::Future, b: Cell<B>) -> Self {
|
fn new(a: A::Future, b: Cell<B>) -> Self {
|
||||||
AndThenFuture {
|
AndThenFuture {
|
||||||
b,
|
b,
|
||||||
fut_a,
|
fut_a: Some(a),
|
||||||
fut_b: None,
|
fut_b: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,8 +91,9 @@ where
|
|||||||
return fut.poll();
|
return fut.poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.fut_a.poll() {
|
match self.fut_a.as_mut().expect("Bug in actix-service").poll() {
|
||||||
Ok(Async::Ready(resp)) => {
|
Ok(Async::Ready(resp)) => {
|
||||||
|
let _ = self.fut_a.take();
|
||||||
self.fut_b = Some(self.b.get_mut().call(resp));
|
self.fut_b = Some(self.b.get_mut().call(resp));
|
||||||
self.poll()
|
self.poll()
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ where
|
|||||||
{
|
{
|
||||||
b: Cell<B>,
|
b: Cell<B>,
|
||||||
fut_b: Option<B::Future>,
|
fut_b: Option<B::Future>,
|
||||||
fut_a: A::Future,
|
fut_a: Option<A::Future>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A, B, Request> ThenFuture<A, B, Request>
|
impl<A, B, Request> ThenFuture<A, B, Request>
|
||||||
@ -69,10 +69,10 @@ where
|
|||||||
A: Service<Request>,
|
A: Service<Request>,
|
||||||
B: Service<Result<A::Response, A::Error>>,
|
B: Service<Result<A::Response, A::Error>>,
|
||||||
{
|
{
|
||||||
fn new(fut_a: A::Future, b: Cell<B>) -> Self {
|
fn new(a: A::Future, b: Cell<B>) -> Self {
|
||||||
ThenFuture {
|
ThenFuture {
|
||||||
b,
|
b,
|
||||||
fut_a,
|
fut_a: Some(a),
|
||||||
fut_b: None,
|
fut_b: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,12 +91,14 @@ where
|
|||||||
return fut.poll();
|
return fut.poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.fut_a.poll() {
|
match self.fut_a.as_mut().expect("bug in actix-service").poll() {
|
||||||
Ok(Async::Ready(resp)) => {
|
Ok(Async::Ready(resp)) => {
|
||||||
|
let _ = self.fut_a.take();
|
||||||
self.fut_b = Some(self.b.get_mut().call(Ok(resp)));
|
self.fut_b = Some(self.b.get_mut().call(Ok(resp)));
|
||||||
self.poll()
|
self.poll()
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
let _ = self.fut_a.take();
|
||||||
self.fut_b = Some(self.b.get_mut().call(Err(err)));
|
self.fut_b = Some(self.b.get_mut().call(Err(err)));
|
||||||
self.poll()
|
self.poll()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user