pub fn block_on<T, F>(future: F) -> T
where
    F: Future<Output = T> + Send + 'static,
    T: Send + 'static,
{
    let handle = spawn(future);

    thread::switch(); // Required to allow Execution to spawn the future

    ExecutionState::with(|state| {
        let me = state.current().id();
        let target = state.get_mut(handle.task_id);
        if target.set_waiter(me) {
            state.current_mut().block();
        }
    });

    thread::switch(); // Required in case the thread blocked

    let result = handle.result.lock().unwrap().take();
    result
        .expect("result should be available to waiter")
        .expect("task should not fail")
}
/// Run a future to completion on the current thread.
Run a future to completion on the current thread.
Run a future to completion on the current thread .
pub fn block_on<T, F>(future: F) -> T
where
    F: Future<Output = T> + Send + 'static,
    T: Send + 'static,
{
    let handle = spawn(future);
    thread::switch(); // Required to allow Execution to spawn the future
    ExecutionState::with(|state| {
        let me = state.current().id();
        let target = state.get_mut(handle.task_id);
        if target.set_waiter(me) {
            state.current_mut().block();
        }
    });
    thread::switch(); // Required in case the thread blocked
    let result = handle.result.lock().unwrap().take();
    result
        .expect("result should be available to waiter")
        .expect("task should not fail")
}
pub fn block_on < T , F > ( future : F ) -> T where F : Future < Output = T > + Send + ' static , T : Send + ' static , { let handle = spawn ( future ) ; thread :: switch ( ) ; // Required to allow Execution to spawn the future ExecutionState :: with ( | state | { let me = state . current ( ) . id ( ) ; let target = state . get_mut ( handle . task_id ) ; if target . set_waiter ( me ) { state . current_mut ( ) . block ( ) ; } } ) ; thread :: switch ( ) ; // Required in case the thread blocked let result = handle . result . lock ( ) . unwrap ( ) . take ( ) ; result . expect ( " " ) . expect ( " " ) }
Run a future to completion on the current thread.
Run a future to completion on the current thread .
future
F
future
F