mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-28 00:00:11 +02:00
test: add a block_on function to tokio-test (#1431)
This commit is contained in:
committed by
Carl Lerche
parent
338b37884a
commit
fe90d61446
@@ -14,6 +14,18 @@ pub mod io;
|
||||
mod macros;
|
||||
pub mod task;
|
||||
|
||||
/// Runs the provided future, blocking the current thread until the
|
||||
/// future completes.
|
||||
///
|
||||
/// For more information, see the documentation for
|
||||
/// [`tokio::runtime::current_thread::Runtime::block_on`][runtime-block-on].
|
||||
///
|
||||
/// [runtime-block-on]: https://docs.rs/tokio/0.2.0-alpha.1/tokio/runtime/current_thread/struct.Runtime.html#method.block_on
|
||||
pub fn block_on<F: std::future::Future>(future: F) -> F::Output {
|
||||
let mut rt = tokio::runtime::current_thread::Runtime::new().unwrap();
|
||||
rt.block_on(future)
|
||||
}
|
||||
|
||||
/*
|
||||
#[doc(hidden)]
|
||||
pub mod codegen {
|
||||
|
||||
Reference in New Issue
Block a user