Skip to content

Commit 00601b9

Browse files
committed
revert function deletion
1 parent 2be8ce6 commit 00601b9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/future/future_group.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,38 @@ impl<F: Future> FutureGroup<F> {
274274
Key(index)
275275
}
276276

277+
#[allow(unused)]
278+
/// Insert a value into a pinned `FutureGroup`
279+
///
280+
/// This method is private because it serves as an implementation detail for
281+
/// `ConcurrentStream`. We should never expose this publicly, as the entire
282+
/// point of this crate is that we abstract the futures poll machinery away
283+
/// from end-users.
284+
pub(crate) fn insert_pinned(self: Pin<&mut Self>, future: F) -> Key
285+
where
286+
F: Future,
287+
{
288+
let mut this = self.project();
289+
// SAFETY: inserting a value into the futures slab does not ever move
290+
// any of the existing values.
291+
let index = unsafe { this.futures.as_mut().get_unchecked_mut() }.insert(future);
292+
this.keys.insert(index);
293+
let key = Key(index);
294+
295+
// If our slab allocated more space we need to
296+
// update our tracking structures along with it.
297+
let max_len = this.futures.as_ref().capacity().max(index);
298+
this.wakers.resize(max_len);
299+
this.states.resize(max_len);
300+
301+
// Set the corresponding state
302+
this.states[index].set_pending();
303+
let mut readiness = this.wakers.readiness();
304+
readiness.set_ready(index);
305+
306+
key
307+
}
308+
277309
/// Create a stream which also yields the key of each item.
278310
///
279311
/// # Example

0 commit comments

Comments
 (0)