pub struct FutureQueue { /* private fields */ }Expand description
A queue for polling futures. It is stored in here until FutureQueue::poll is run.
Implementations§
Source§impl FutureQueue
impl FutureQueue
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new Arc<FutureQueue>.
Sourcepub fn push<F, T>(&self, future: F) -> FutureHandle
pub fn push<F, T>(&self, future: F) -> FutureHandle
Pushes a future to the FutureQueue. It will sit and wait
to be processed until FutureQueue::poll is called.
Sourcepub fn poll(&self)
pub fn poll(&self)
Polls all the futures in the future queue and resolves the handles.
This function spawns a new async thread for each item inside the thread and sends updates to the Handle’s receiver.
Sourcepub fn exchange(&self, handle: &FutureHandle) -> Option<AnyResult>
pub fn exchange(&self, handle: &FutureHandle) -> Option<AnyResult>
Exchanges the future for the result.
When the handle is not successful, it will return nothing. When the handle is successful, it will return the result and drop the handle, removing the usage of it.
Sourcepub fn exchange_as<T: Any + Send + Sync + 'static>(
&self,
handle: &FutureHandle,
) -> Option<Arc<T>>
pub fn exchange_as<T: Any + Send + Sync + 'static>( &self, handle: &FutureHandle, ) -> Option<Arc<T>>
Exchanges the handle and safely downcasts it into a specific type.
Sourcepub fn get_status(&self, handle: &FutureHandle) -> Option<FutureStatus>
pub fn get_status(&self, handle: &FutureHandle) -> Option<FutureStatus>
Get status of a handle
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FutureQueue
impl !RefUnwindSafe for FutureQueue
impl Send for FutureQueue
impl Sync for FutureQueue
impl Unpin for FutureQueue
impl !UnwindSafe for FutureQueue
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