From d9715ff831587af74867141c463338f5ccccb8f2 Mon Sep 17 00:00:00 2001 From: Matheus Consoli Date: Sat, 23 Mar 2024 12:05:26 -0300 Subject: [PATCH] Fix `feature(alloc)` for `InnerGroup` --- src/collections/inner_group.rs | 13 +++---------- src/collections/mod.rs | 1 + src/future/future_group.rs | 8 +++++++- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/collections/inner_group.rs b/src/collections/inner_group.rs index 257f3cb..136e008 100644 --- a/src/collections/inner_group.rs +++ b/src/collections/inner_group.rs @@ -113,18 +113,10 @@ impl InnerGroup { self.cap = cap; } - pub fn any_ready(&self) -> bool { - self.wakers.readiness().any_ready() - } - pub fn set_top_waker(&mut self, waker: &Waker) { self.wakers.readiness().set_waker(waker); } - pub fn can_progress_index(&self, index: usize) -> bool { - self.states[index].is_pending() && self.wakers.readiness().clear_ready(index) - } - // move to other impl block pub fn contains_key(&self, key: Key) -> bool { self.items.contains(key.0) @@ -171,7 +163,7 @@ where // set the top-level waker and check readiness this.set_top_waker(cx.waker()); - if !this.any_ready() { + if !this.wakers.readiness().any_ready() { // nothing is ready yet return Poll::Pending; } @@ -183,7 +175,8 @@ where let mut ret = Poll::Pending; for index in this.keys.iter().cloned() { - if !this.can_progress_index(index) { + // can we make progress for this item? + if !(this.states[index].is_pending() && this.wakers.readiness().clear_ready(index)) { continue; } diff --git a/src/collections/mod.rs b/src/collections/mod.rs index 37fb814..cf6ca7e 100644 --- a/src/collections/mod.rs +++ b/src/collections/mod.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "alloc")] pub(crate) mod inner_group; #[cfg(feature = "alloc")] pub mod vec; diff --git a/src/future/future_group.rs b/src/future/future_group.rs index 5a6b0bc..415faa0 100644 --- a/src/future/future_group.rs +++ b/src/future/future_group.rs @@ -75,7 +75,7 @@ impl FutureGroup { /// # let group: FutureGroup> = group; /// ``` pub fn new() -> Self { - Self::with_capacity(0) + Self::default() } /// Create a new instance of `FutureGroup` with a given capacity. @@ -188,6 +188,12 @@ impl FutureGroup { } } +impl Default for FutureGroup { + fn default() -> Self { + Self::with_capacity(0) + } +} + impl FutureGroup { /// Insert a new future into the group. ///