[][src]Function safina::block_on

pub fn block_on<R>(fut: impl Send + Future<Output = R> + 'static) -> R

Executes the future on the current thread and returns its result. Panics if the future panics.

fut can call spawn to create tasks. Those tasks will execute on worker threads even after fut completes and this thread returns.

Uses std::boxed::Box::pin to make the future Unpin. You can use block_on_unpin to avoid this allocation.

std::thread::spawn(safina_executor::work);
let result = safina_executor::block_on(async {
    prepare_request().await?;
    execute_request().await
})?;