summaryrefslogtreecommitdiff
path: root/cli/tokio_util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tokio_util.rs')
-rw-r--r--cli/tokio_util.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/cli/tokio_util.rs b/cli/tokio_util.rs
index fea47792e..ec1e0e3cf 100644
--- a/cli/tokio_util.rs
+++ b/cli/tokio_util.rs
@@ -1,30 +1,30 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-use futures;
-use futures::future::FutureExt;
-use futures::future::TryFutureExt;
use std::future::Future;
use tokio;
use tokio::runtime;
-pub fn create_threadpool_runtime(
-) -> Result<tokio::runtime::Runtime, tokio::io::Error> {
- runtime::Builder::new()
- .panic_handler(|err| std::panic::resume_unwind(err))
- .build()
-}
-
pub fn run<F>(future: F)
where
F: Future<Output = Result<(), ()>> + Send + 'static,
{
- // tokio::runtime::current_thread::run(future)
- let rt = create_threadpool_runtime().expect("Unable to create Tokio runtime");
- rt.block_on_all(future.boxed().compat()).unwrap();
+ let mut rt = runtime::Builder::new()
+ .threaded_scheduler()
+ .enable_all()
+ .thread_name("deno")
+ .build()
+ .expect("Unable to create Tokio runtime");
+ rt.block_on(future).unwrap();
}
pub fn run_on_current_thread<F>(future: F)
where
F: Future<Output = Result<(), ()>> + Send + 'static,
{
- tokio::runtime::current_thread::run(future.boxed().compat());
+ let mut rt = runtime::Builder::new()
+ .basic_scheduler()
+ .enable_all()
+ .thread_name("deno")
+ .build()
+ .expect("Unable to create Tokio runtime");
+ rt.block_on(future).unwrap();
}