refactor: move mod tokio_util to runtime (#12332)

This avoids a bunch of duplicated code.
This commit is contained in:
Bert Belder 2021-10-21 13:05:43 +02:00
parent b042697902
commit f1b1a3f389
No known key found for this signature in database
GPG key ID: 7A77887B2E2ED461
9 changed files with 21 additions and 40 deletions

View file

@ -13,3 +13,13 @@ pub fn create_basic_runtime() -> tokio::runtime::Runtime {
.build()
.unwrap()
}
// TODO(ry) rename to run_local ?
pub fn run_basic<F, R>(future: F) -> R
where
F: std::future::Future<Output = R>,
{
let rt = create_basic_runtime();
let local = tokio::task::LocalSet::new();
local.block_on(&rt, future)
}