Skip to content

Commit

Permalink
Fix un-needed wakeups for unready future
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Nov 10, 2024
1 parent 0a37645 commit 9c8c33f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
4 changes: 4 additions & 0 deletions ntex-service/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes

## [3.3.2] - 2024-11-10

* Fix un-needed wakeups for unready future

## [3.3.1] - 2024-11-04

* Optimize readiness handling
Expand Down
2 changes: 1 addition & 1 deletion ntex-service/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ntex-service"
version = "3.3.1"
version = "3.3.2"
authors = ["ntex contributors <team@ntex.rs>"]
description = "ntex service"
keywords = ["network", "framework", "async", "futures"]
Expand Down
9 changes: 0 additions & 9 deletions ntex-service/src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ pub(crate) struct WaitersRef {
impl WaitersRef {
pub(crate) fn new() -> (u32, Self) {
let mut waiters = slab::Slab::new();

// first insert for wake ups from services
let _ = waiters.insert(None);

(
waiters.insert(Default::default()) as u32,
WaitersRef {
Expand Down Expand Up @@ -66,11 +62,6 @@ impl WaitersRef {
self.get()[idx as usize] = Some(cx.waker().clone());
}

pub(crate) fn register_unready(&self, cx: &mut Context<'_>) {
self.get()[0] = Some(cx.waker().clone());
self.get_wakers().push(0);
}

pub(crate) fn notify(&self) {
let wakers = self.get_wakers();
if !wakers.is_empty() {
Expand Down
5 changes: 1 addition & 4 deletions ntex-service/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,7 @@ where
}
let fut = slf.fut.as_mut().unwrap();
match unsafe { Pin::new_unchecked(fut) }.poll(cx) {
Poll::Pending => {
slf.pl.state.waiters.register_unready(cx);
Poll::Pending
}
Poll::Pending => Poll::Pending,
Poll::Ready(res) => {
let _ = slf.fut.take();
slf.pl.state.waiters.notify();
Expand Down

0 comments on commit 9c8c33f

Please sign in to comment.