Enable thread pool for blocking ops (#3912)

This commit is contained in:
Ryan Dahl 2020-02-07 17:54:44 -05:00 committed by GitHub
parent 99186dbaa2
commit 724e39f13f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 11 deletions

View file

@ -1,5 +1,4 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use futures::Future;
// TODO(ry) rename to run_local ?
pub fn run_basic<F, R>(future: F) -> R
@ -15,7 +14,9 @@ where
rt.block_on(future)
}
pub fn spawn_thread<F, R>(f: F) -> impl Future<Output = R>
// TODO(ry) maybe replace with tokio::task::spawn_blocking
#[cfg(test)]
pub fn spawn_thread<F, R>(f: F) -> impl std::future::Future<Output = R>
where
F: 'static + Send + FnOnce() -> R,
R: 'static + Send,