/// Spawns a future running concurrently with the caller.
///
/// Note: the main purpose of this function is to kick-start top-level canister
/// async method calls.
Spawns a future running concurrently with the caller.
Note: the main purpose of this function is to kick-start top-level canister
async method calls.
Spawns a future running concurrently with the caller . Note : the main purpose of this function is to kick - start top - level canister async method calls .
pub fn spawn<F: 'static + Future<Output = ()>>(future: F) {
    let top_level_future = Box::new(TopLevelFuture {
        future: Box::pin(future),
        ref_count: 1,
    });
    let top_level_future_ptr = Box::into_raw(top_level_future);
    let _guard = TopLevelFutureGuard::new(top_level_future_ptr);
    if unsafe {
        (*top_level_future_ptr)
            .future
            .as_mut()
            .poll(&mut Context::from_waker(&waker::waker(
                top_level_future_ptr as *const (),
            )))
    }
    .is_ready()
    {
        unsafe {
            TopLevelFuture::release(top_level_future_ptr);
        }
    }
}
pub fn spawn < F : ' static + Future < Output = ( ) > > ( future : F ) { let top_level_future = Box :: new ( TopLevelFuture { future : Box :: pin ( future ) , ref_count : 1 , } ) ; let top_level_future_ptr = Box :: into_raw ( top_level_future ) ; let _guard = TopLevelFutureGuard :: new ( top_level_future_ptr ) ; if unsafe { ( * top_level_future_ptr ) . future . as_mut ( ) . poll ( & mut Context :: from_waker ( & waker :: waker ( top_level_future_ptr as * const ( ) , ) ) ) } . is_ready ( ) { unsafe { TopLevelFuture :: release ( top_level_future_ptr ) ; } } }
Spawns a future running concurrently with the caller.
Spawns a future running concurrently with the caller .
future
F