pub struct Pool<T> { /* private fields */ }
Expand description
An unordered pool of futures.
Futures can be added to the pool, and removed from the pool as they resolve.
Note: This pool is not thread-safe and should not be used across threads without external synchronization.
Implementations§
Source§impl<T: Send> Pool<T>
impl<T: Send> Pool<T>
Sourcepub fn push(&mut self, future: impl Future<Output = T> + Send + 'static)
pub fn push(&mut self, future: impl Future<Output = T> + Send + 'static)
Adds a future to the pool.
The future must be 'static
and Send
to ensure it can be safely stored and executed.
Sourcepub fn next_completed(
&mut self,
) -> SelectNextSome<'_, FuturesUnordered<Pin<Box<dyn Future<Output = T> + Send>>>>
pub fn next_completed( &mut self, ) -> SelectNextSome<'_, FuturesUnordered<Pin<Box<dyn Future<Output = T> + Send>>>>
Returns a futures that resolves to the next future in the pool that resolves.
If the pool is empty, the future will never resolve.
Sourcepub fn cancel_all(&mut self)
pub fn cancel_all(&mut self)
Cancels all futures in the pool.
Excludes the dummy future.
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for Pool<T>
impl<T> !RefUnwindSafe for Pool<T>
impl<T> Send for Pool<T>
impl<T> !Sync for Pool<T>
impl<T> Unpin for Pool<T>
impl<T> !UnwindSafe for Pool<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more