mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-05 05:47:40 +03:00
Fix un-needed wakeups for unready future (#462)
This commit is contained in:
parent
0a376457f1
commit
5700a50f56
4 changed files with 6 additions and 14 deletions
|
@ -1,5 +1,9 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [3.3.2] - 2024-11-10
|
||||||
|
|
||||||
|
* Fix un-needed wakeups for unready future
|
||||||
|
|
||||||
## [3.3.1] - 2024-11-04
|
## [3.3.1] - 2024-11-04
|
||||||
|
|
||||||
* Optimize readiness handling
|
* Optimize readiness handling
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "ntex-service"
|
name = "ntex-service"
|
||||||
version = "3.3.1"
|
version = "3.3.2"
|
||||||
authors = ["ntex contributors <team@ntex.rs>"]
|
authors = ["ntex contributors <team@ntex.rs>"]
|
||||||
description = "ntex service"
|
description = "ntex service"
|
||||||
keywords = ["network", "framework", "async", "futures"]
|
keywords = ["network", "framework", "async", "futures"]
|
||||||
|
|
|
@ -19,10 +19,6 @@ pub(crate) struct WaitersRef {
|
||||||
impl WaitersRef {
|
impl WaitersRef {
|
||||||
pub(crate) fn new() -> (u32, Self) {
|
pub(crate) fn new() -> (u32, Self) {
|
||||||
let mut waiters = slab::Slab::new();
|
let mut waiters = slab::Slab::new();
|
||||||
|
|
||||||
// first insert for wake ups from services
|
|
||||||
let _ = waiters.insert(None);
|
|
||||||
|
|
||||||
(
|
(
|
||||||
waiters.insert(Default::default()) as u32,
|
waiters.insert(Default::default()) as u32,
|
||||||
WaitersRef {
|
WaitersRef {
|
||||||
|
@ -66,11 +62,6 @@ impl WaitersRef {
|
||||||
self.get()[idx as usize] = Some(cx.waker().clone());
|
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) {
|
pub(crate) fn notify(&self) {
|
||||||
let wakers = self.get_wakers();
|
let wakers = self.get_wakers();
|
||||||
if !wakers.is_empty() {
|
if !wakers.is_empty() {
|
||||||
|
|
|
@ -464,10 +464,7 @@ where
|
||||||
}
|
}
|
||||||
let fut = slf.fut.as_mut().unwrap();
|
let fut = slf.fut.as_mut().unwrap();
|
||||||
match unsafe { Pin::new_unchecked(fut) }.poll(cx) {
|
match unsafe { Pin::new_unchecked(fut) }.poll(cx) {
|
||||||
Poll::Pending => {
|
Poll::Pending => Poll::Pending,
|
||||||
slf.pl.state.waiters.register_unready(cx);
|
|
||||||
Poll::Pending
|
|
||||||
}
|
|
||||||
Poll::Ready(res) => {
|
Poll::Ready(res) => {
|
||||||
let _ = slf.fut.take();
|
let _ = slf.fut.take();
|
||||||
slf.pl.state.waiters.notify();
|
slf.pl.state.waiters.notify();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue