Skip to content

Commit

Permalink
Fix feature(alloc) for InnerGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
matheus-consoli committed Mar 23, 2024
1 parent 899f32b commit d9715ff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
13 changes: 3 additions & 10 deletions src/collections/inner_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,10 @@ impl<A, B> InnerGroup<A, B> {
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)
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/collections/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(feature = "alloc")]
pub(crate) mod inner_group;
#[cfg(feature = "alloc")]
pub mod vec;
8 changes: 7 additions & 1 deletion src/future/future_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<F> FutureGroup<F> {
/// # let group: FutureGroup<core::future::Ready<usize>> = group;
/// ```
pub fn new() -> Self {
Self::with_capacity(0)
Self::default()
}

/// Create a new instance of `FutureGroup` with a given capacity.
Expand Down Expand Up @@ -188,6 +188,12 @@ impl<F> FutureGroup<F> {
}
}

impl<F> Default for FutureGroup<F> {
fn default() -> Self {
Self::with_capacity(0)
}
}

impl<F: Future> FutureGroup<F> {
/// Insert a new future into the group.
///
Expand Down

0 comments on commit d9715ff

Please sign in to comment.