pub fn run<F, T>(future: F, stack: ProcStack) -> T
where
    F: Future<Output = T>,
{
    unsafe {
        // A place on the stack where the result will be stored.
        let out = &mut UnsafeCell::new(None);

        // Wrap the future into one that stores the result into `out`.
        let future = {
            let out = out.get();

            async move {
                *out = Some(future.await);
            }
        };

        // Pin the future onto the stack.
        pin_utils::pin_mut!(future);

        // Transmute the future into one that is futurestatic.
        let future = mem::transmute::<
            Pin<&'_ mut dyn Future<Output = ()>>,
            Pin<&'static mut dyn Future<Output = ()>>,
        >(future);

        // Block on the future and and wait for it to complete.
        worker::set_stack(&stack, || block(future));

        // Take out the result.
        match (*out.get()).take() {
            Some(v) => v,
            _ => unimplemented!(),
        }
    }
}
///
/// This method blocks the current thread until passed future is resolved with an output (including the panic).
///
/// It is called `block_on` or `blocking` in some executors.
///
/// # Example
/// ```rust
/// use bastion_executor::prelude::*;
/// use lightproc::prelude::*;
/// let mut sum = 0;
///
/// run(
///     async {
///         (0..10_000_000).for_each(|_| {
///             sum += 1;
///         });
///     },
///     ProcStack::default(),
/// );
/// ```
This method blocks the current thread until passed future is resolved with an output (including the panic).
It is called `block_on` or `blocking` in some executors.
This method blocks the current thread until passed future is resolved with an output ( including the panic ) . It is called ` block_on ` or ` blocking ` in some executors .
pub fn run<F, T>(future: F, stack: ProcStack) -> T
where
    F: Future<Output = T>,
{
    unsafe {
        // A place on the stack where the result will be stored.
        let out = &mut UnsafeCell::new(None);
        // Wrap the future into one that stores the result into `out`.
        let future = {
            let out = out.get();
            async move {
                *out = Some(future.await);
            }
        };
        // Pin the future onto the stack.
        pin_utils::pin_mut!(future);
        // Transmute the future into one that is futurestatic.
        let future = mem::transmute::<
            Pin<&'_ mut dyn Future<Output = ()>>,
            Pin<&'static mut dyn Future<Output = ()>>,
        >(future);
        // Block on the future and and wait for it to complete.
        worker::set_stack(&stack, || block(future));
        // Take out the result.
        match (*out.get()).take() {
            Some(v) => v,
            _ => unimplemented!(),
        }
    }
}
pub fn run < F , T > ( future : F , stack : ProcStack ) -> T where F : Future < Output = T > , { unsafe { // A place on the stack where the result will be stored. let out = & mut UnsafeCell :: new ( None ) ; // Wrap the future into one that stores the result into `out`. let future = { let out = out . get ( ) ; async move { * out = Some ( future . await ) ; } } ; // Pin the future onto the stack. pin_utils :: pin_mut ! ( future ) ; // Transmute the future into one that is futurestatic. let future = mem :: transmute :: < Pin < & ' _ mut dyn Future < Output = ( ) > > , Pin < & ' static mut dyn Future < Output = ( ) > > , > ( future ) ; // Block on the future and and wait for it to complete. worker :: set_stack ( & stack , | | block ( future ) ) ; // Take out the result. match ( * out . get ( ) ) . take ( ) { Some ( v ) => v , _ => unimplemented ! ( ) , } } }
This method blocks the current thread until passed future is resolved with an output (including the panic).
This method blocks the current thread until passed future is resolved with an output ( including the panic ) .
future
F
stack
ProcStack
future
F
stack
ProcStack
example
```rust
use bastion_executor::prelude::*;
use lightproc::prelude::*;
let mut sum = 0.


` ` ` rust use bastion_executor :: prelude :: * ; use lightproc :: prelude :: * ; let mut sum = 0 .