pub fn block_on<F>(mut future: F, mut on_pending: impl FnMut(), waker: &Waker) -> F::Output where F: Future {
    // SAFETY: we know this future is on stack and cannot be moved in other way
    // because this block shadows it, preventing from access.
    let mut future = unsafe { Pin::new_unchecked(&mut future) };
    let mut ctx = Context::from_waker(waker);
    loop {
        match future.as_mut().poll(&mut ctx) {
            Poll::Ready(value) => break value,
            Poll::Pending => { on_pending(); }
        }
    }
}
/// Utility for blocking on future with custom waker and pending action.
///
/// # Examples
/// ```
/// use juggle::*;
/// use juggle::utils::noop_waker;
///
/// let mut yield_count = 0;
/// let future = async move{
///     Yield::times(10).await;
///     20
/// };
///
/// let result = block_on(future,||{ yield_count +=1; },&noop_waker());
/// assert_eq!(result,20);
/// assert_eq!(yield_count,10);
/// ```
Utility for blocking on future with custom waker and pending action.
Utility for blocking on future with custom waker and pending action .
pub fn block_on<F>(mut future: F, mut on_pending: impl FnMut(), waker: &Waker) -> F::Output where F: Future {
    // SAFETY: we know this future is on stack and cannot be moved in other way
    // because this block shadows it, preventing from access.
    let mut future = unsafe { Pin::new_unchecked(&mut future) };
    let mut ctx = Context::from_waker(waker);
    loop {
        match future.as_mut().poll(&mut ctx) {
            Poll::Ready(value) => break value,
            Poll::Pending => { on_pending(); }
        }
    }
}
pub fn block_on < F > ( mut future : F , mut on_pending : impl FnMut ( ) , waker : & Waker ) -> F :: Output where F : Future { // SAFETY: we know this future is on stack and cannot be moved in other way // because this block shadows it, preventing from access. let mut future = unsafe { Pin :: new_unchecked ( & mut future ) } ; let mut ctx = Context :: from_waker ( waker ) ; loop { match future . as_mut ( ) . poll ( & mut ctx ) { Poll :: Ready ( value ) => break value , Poll :: Pending => { on_pending ( ) ; } } } }
Utility for blocking on future with custom waker and pending action.
Utility for blocking on future with custom waker and pending action .
future
F
on_pending
impl FnMut()
waker
&Waker
future
F
on_pending
impl FnMut()
waker
&Waker
examples
```
use juggle::*;
use juggle::utils::noop_waker.

let mut yield_count = 0;
let future = async move{
Yield::times(10).await;
20
}.


` ` ` use juggle :: * ; use juggle :: utils :: noop_waker . let mut yield_count = 0 ; let future = async move { Yield :: times ( 10 ) . await ; 20 } .