Skip to main content

block_on

Function block_on 

Source
pub fn block_on<F, T>(future: F) -> T
where F: Future<Output = T> + Send + 'static, T: Send + 'static,
Expand description

Block on a future to completion 阻塞等待future完成

This function will block the current thread until the future completes. 此函数将阻塞当前线程直到future完成。

§Example / 示例

use hiver_runtime::task::block_on;

block_on(async {
    println!("Hello from async!");
});

Note: This creates a temporary runtime for the execution. 注意:这会创建一个临时运行时来执行。