mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 15:06:54 -05:00
2e74f164b6
This commit moves Deno JS runtime, ops, permissions and inspector implementation to new "deno_runtime" crate located in "runtime/" directory. Details in "runtime/README.md". Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
25 lines
782 B
Rust
25 lines
782 B
Rust
// 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()
|
|
// This limits the number of threads for blocking operations (like for
|
|
// synchronous fs ops) or CPU bound tasks like when we run dprint in
|
|
// parallel for deno fmt.
|
|
// The default value is 512, which is an unhelpfully large thread pool. We
|
|
// don't ever want to have more than a couple dozen threads.
|
|
.max_threads(32)
|
|
.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 mut rt = create_basic_runtime();
|
|
rt.block_on(future)
|
|
}
|