deno/cli/tokio_util.rs

20 lines
449 B
Rust
Raw Normal View History

2020-01-02 20:13:47 +00:00
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
pub fn create_basic_runtime() -> tokio::runtime::Runtime {
tokio::runtime::Builder::new()
.basic_scheduler()
.enable_io()
.enable_time()
2019-12-30 13:57:17 +00:00
.build()
.unwrap()
}
// TODO(ry) rename to run_local ?
pub fn run_basic<F, R>(future: F) -> R
where
F: std::future::Future<Output = R> + 'static,
{
let mut rt = create_basic_runtime();
rt.block_on(future)
}