diff options
author | Bert Belder <bertbelder@gmail.com> | 2021-10-21 13:05:43 +0200 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2021-11-08 12:49:11 -0800 |
commit | f1b1a3f389827af8983a78680c066fdad337ae32 (patch) | |
tree | 7eaaac2b3094d40bc9fa4a453988ad7ddb4f37cd /cli/tokio_util.rs | |
parent | b0426979029fe1923def25462f9b36b51c1263ec (diff) |
refactor: move `mod tokio_util` to runtime (#12332)
This avoids a bunch of duplicated code.
Diffstat (limited to 'cli/tokio_util.rs')
-rw-r--r-- | cli/tokio_util.rs | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/cli/tokio_util.rs b/cli/tokio_util.rs deleted file mode 100644 index 695b94802..000000000 --- a/cli/tokio_util.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - -pub fn create_basic_runtime() -> tokio::runtime::Runtime { - tokio::runtime::Builder::new_current_thread() - .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_blocking_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 rt = create_basic_runtime(); - let local = tokio::task::LocalSet::new(); - local.block_on(&rt, future) -} |