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;
|
2018-09-18 14:53:16 -04:00
|
|
|
use tokio;
|
2019-04-23 16:27:44 -04:00
|
|
|
use tokio::runtime;
|
|
|
|
|
2019-03-14 19:17:52 -04:00
|
|
|
pub fn run<F>(future: F)
|
|
|
|
where
|
2020-01-01 09:51:27 -05:00
|
|
|
F: Future<Output = ()> + Send + 'static,
|
2019-03-14 19:17:52 -04:00
|
|
|
{
|
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");
|
2020-01-01 09:51:27 -05:00
|
|
|
rt.block_on(future);
|
2019-04-14 16:07:24 -04:00
|
|
|
}
|