1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-04 08:54:20 -05:00
denoland-deno/cli/tokio_util.rs

31 lines
686 B
Rust
Raw Normal View History

2020-01-02 15:13:47 -05:00
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
2019-11-16 19:17:47 -05:00
use std::future::Future;
use tokio;
use tokio::runtime;
pub fn run<F>(future: F)
where
F: Future<Output = ()> + Send + 'static,
{
2019-12-30 08:57:17 -05:00
let mut rt = runtime::Builder::new()
.threaded_scheduler()
.enable_all()
.thread_name("deno")
.build()
.expect("Unable to create Tokio runtime");
rt.block_on(future);
}
2019-07-31 11:02:20 -04:00
pub fn run_on_current_thread<F>(future: F)
where
F: Future<Output = ()> + Send + 'static,
2019-07-31 11:02:20 -04:00
{
2019-12-30 08:57:17 -05:00
let mut rt = runtime::Builder::new()
.basic_scheduler()
.enable_all()
.thread_name("deno")
.build()
.expect("Unable to create Tokio runtime");
rt.block_on(future);
2019-07-31 11:02:20 -04:00
}