deno.land / x / deno@v1.28.2 / runtime / tokio_util.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright 2018-2022 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()}
pub fn run_local<F, R>(future: F) -> Rwhere F: std::future::Future<Output = R>,{ let rt = create_basic_runtime(); let local = tokio::task::LocalSet::new(); local.block_on(&rt, future)}
deno

Version Info

Tagged at
a year ago