summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/cache/sqlite.rs13
-rw-r--r--ext/crypto/decrypt.rs3
-rw-r--r--ext/crypto/encrypt.rs3
-rw-r--r--ext/crypto/generate_key.rs3
-rw-r--r--ext/crypto/lib.rs3
-rw-r--r--ext/ffi/call.rs5
-rw-r--r--ext/fs/std_fs.rs43
-rw-r--r--ext/http/http_next.rs19
-rw-r--r--ext/http/lib.rs8
-rw-r--r--ext/io/lib.rs5
-rw-r--r--ext/net/ops_tls.rs6
-rw-r--r--ext/node/ops/crypto/mod.rs48
-rw-r--r--ext/websocket/lib.rs2
13 files changed, 73 insertions, 88 deletions
diff --git a/ext/cache/sqlite.rs b/ext/cache/sqlite.rs
index 2853f793d..4eb9924c7 100644
--- a/ext/cache/sqlite.rs
+++ b/ext/cache/sqlite.rs
@@ -10,6 +10,7 @@ use std::time::UNIX_EPOCH;
use async_trait::async_trait;
use deno_core::error::AnyError;
use deno_core::parking_lot::Mutex;
+use deno_core::task::spawn_blocking;
use deno_core::AsyncRefCell;
use deno_core::AsyncResult;
use deno_core::ByteString;
@@ -99,7 +100,7 @@ impl Cache for SqliteBackedCache {
async fn storage_open(&self, cache_name: String) -> Result<i64, AnyError> {
let db = self.connection.clone();
let cache_storage_dir = self.cache_storage_dir.clone();
- tokio::task::spawn_blocking(move || {
+ spawn_blocking(move || {
let db = db.lock();
db.execute(
"INSERT OR IGNORE INTO cache_storage (cache_name) VALUES (?1)",
@@ -124,7 +125,7 @@ impl Cache for SqliteBackedCache {
/// Note: this doesn't check the disk, it only checks the sqlite db.
async fn storage_has(&self, cache_name: String) -> Result<bool, AnyError> {
let db = self.connection.clone();
- tokio::task::spawn_blocking(move || {
+ spawn_blocking(move || {
let db = db.lock();
let cache_exists = db.query_row(
"SELECT count(id) FROM cache_storage WHERE cache_name = ?1",
@@ -143,7 +144,7 @@ impl Cache for SqliteBackedCache {
async fn storage_delete(&self, cache_name: String) -> Result<bool, AnyError> {
let db = self.connection.clone();
let cache_storage_dir = self.cache_storage_dir.clone();
- tokio::task::spawn_blocking(move || {
+ spawn_blocking(move || {
let db = db.lock();
let maybe_cache_id = db
.query_row(
@@ -210,7 +211,7 @@ impl Cache for SqliteBackedCache {
> {
let db = self.connection.clone();
let cache_storage_dir = self.cache_storage_dir.clone();
- let query_result = tokio::task::spawn_blocking(move || {
+ let query_result = spawn_blocking(move || {
let db = db.lock();
let result = db.query_row(
"SELECT response_body_key, response_headers, response_status, response_status_text, request_headers
@@ -269,7 +270,7 @@ impl Cache for SqliteBackedCache {
request: CacheDeleteRequest,
) -> Result<bool, AnyError> {
let db = self.connection.clone();
- tokio::task::spawn_blocking(move || {
+ spawn_blocking(move || {
// TODO(@satyarohith): remove the response body from disk if one exists
let db = db.lock();
let rows_effected = db.execute(
@@ -287,7 +288,7 @@ async fn insert_cache_asset(
put: CachePutRequest,
response_body_key: Option<String>,
) -> Result<Option<String>, deno_core::anyhow::Error> {
- tokio::task::spawn_blocking(move || {
+ spawn_blocking(move || {
let maybe_response_body = {
let db = db.lock();
db.query_row(
diff --git a/ext/crypto/decrypt.rs b/ext/crypto/decrypt.rs
index 6c4d5b6ba..fc54fe818 100644
--- a/ext/crypto/decrypt.rs
+++ b/ext/crypto/decrypt.rs
@@ -20,6 +20,7 @@ use deno_core::error::custom_error;
use deno_core::error::type_error;
use deno_core::error::AnyError;
use deno_core::op;
+use deno_core::task::spawn_blocking;
use deno_core::ZeroCopyBuf;
use rsa::pkcs1::DecodeRsaPrivateKey;
use rsa::PaddingScheme;
@@ -98,7 +99,7 @@ pub async fn op_crypto_decrypt(
tag_length,
} => decrypt_aes_gcm(key, length, tag_length, iv, additional_data, &data),
};
- let buf = tokio::task::spawn_blocking(fun).await.unwrap()?;
+ let buf = spawn_blocking(fun).await.unwrap()?;
Ok(buf.into())
}
diff --git a/ext/crypto/encrypt.rs b/ext/crypto/encrypt.rs
index f34e0cbc6..2831ca0f4 100644
--- a/ext/crypto/encrypt.rs
+++ b/ext/crypto/encrypt.rs
@@ -19,6 +19,7 @@ use ctr::Ctr64BE;
use deno_core::error::type_error;
use deno_core::error::AnyError;
use deno_core::op;
+use deno_core::task::spawn_blocking;
use deno_core::ZeroCopyBuf;
use rand::rngs::OsRng;
use rsa::pkcs1::DecodeRsaPublicKey;
@@ -99,7 +100,7 @@ pub async fn op_crypto_encrypt(
key_length,
} => encrypt_aes_ctr(key, key_length, &counter, ctr_length, &data),
};
- let buf = tokio::task::spawn_blocking(fun).await.unwrap()?;
+ let buf = spawn_blocking(fun).await.unwrap()?;
Ok(buf.into())
}
diff --git a/ext/crypto/generate_key.rs b/ext/crypto/generate_key.rs
index 2a9452c43..426c61376 100644
--- a/ext/crypto/generate_key.rs
+++ b/ext/crypto/generate_key.rs
@@ -2,6 +2,7 @@
use deno_core::error::AnyError;
use deno_core::op;
+use deno_core::task::spawn_blocking;
use deno_core::ZeroCopyBuf;
use elliptic_curve::rand_core::OsRng;
use num_traits::FromPrimitive;
@@ -56,7 +57,7 @@ pub async fn op_crypto_generate_key(
generate_key_hmac(hash, length)
}
};
- let buf = tokio::task::spawn_blocking(fun).await.unwrap()?;
+ let buf = spawn_blocking(fun).await.unwrap()?;
Ok(buf.into())
}
diff --git a/ext/crypto/lib.rs b/ext/crypto/lib.rs
index f481f97f6..05349bf68 100644
--- a/ext/crypto/lib.rs
+++ b/ext/crypto/lib.rs
@@ -10,6 +10,7 @@ use deno_core::error::type_error;
use deno_core::error::AnyError;
use deno_core::op;
+use deno_core::task::spawn_blocking;
use deno_core::OpState;
use deno_core::ZeroCopyBuf;
use serde::Deserialize;
@@ -601,7 +602,7 @@ pub async fn op_crypto_subtle_digest(
algorithm: CryptoHash,
data: ZeroCopyBuf,
) -> Result<ZeroCopyBuf, AnyError> {
- let output = tokio::task::spawn_blocking(move || {
+ let output = spawn_blocking(move || {
digest::digest(algorithm.into(), &data)
.as_ref()
.to_vec()
diff --git a/ext/ffi/call.rs b/ext/ffi/call.rs
index 98186936c..21358d851 100644
--- a/ext/ffi/call.rs
+++ b/ext/ffi/call.rs
@@ -15,6 +15,7 @@ use deno_core::op;
use deno_core::serde_json::Value;
use deno_core::serde_v8;
use deno_core::serde_v8::ExternalPointer;
+use deno_core::task::spawn_blocking;
use deno_core::v8;
use deno_core::OpState;
use deno_core::ResourceId;
@@ -298,7 +299,7 @@ where
.map(|v| v8::Local::<v8::TypedArray>::try_from(v.v8_value).unwrap());
let out_buffer_ptr = out_buffer_as_ptr(scope, out_buffer);
- let join_handle = tokio::task::spawn_blocking(move || {
+ let join_handle = spawn_blocking(move || {
let PtrSymbol { cif, ptr } = symbol.clone();
ffi_call(
call_args,
@@ -345,7 +346,7 @@ pub fn op_ffi_call_nonblocking<'scope>(
.map(|v| v8::Local::<v8::TypedArray>::try_from(v.v8_value).unwrap());
let out_buffer_ptr = out_buffer_as_ptr(scope, out_buffer);
- let join_handle = tokio::task::spawn_blocking(move || {
+ let join_handle = spawn_blocking(move || {
let Symbol {
cif,
ptr,
diff --git a/ext/fs/std_fs.rs b/ext/fs/std_fs.rs
index 6ac935bbd..9baf74a2a 100644
--- a/ext/fs/std_fs.rs
+++ b/ext/fs/std_fs.rs
@@ -9,6 +9,7 @@ use std::path::Path;
use std::path::PathBuf;
use std::rc::Rc;
+use deno_core::task::spawn_blocking;
use deno_io::fs::File;
use deno_io::fs::FsResult;
use deno_io::fs::FsStat;
@@ -86,8 +87,7 @@ impl FileSystem for RealFs {
options: OpenOptions,
) -> FsResult<Rc<dyn File>> {
let opts = open_options(options);
- let std_file =
- tokio::task::spawn_blocking(move || opts.open(path)).await??;
+ let std_file = spawn_blocking(move || opts.open(path)).await??;
Ok(Rc::new(StdFileResourceInner::file(std_file)))
}
@@ -105,14 +105,14 @@ impl FileSystem for RealFs {
recursive: bool,
mode: u32,
) -> FsResult<()> {
- tokio::task::spawn_blocking(move || mkdir(&path, recursive, mode)).await?
+ spawn_blocking(move || mkdir(&path, recursive, mode)).await?
}
fn chmod_sync(&self, path: &Path, mode: u32) -> FsResult<()> {
chmod(path, mode)
}
async fn chmod_async(&self, path: PathBuf, mode: u32) -> FsResult<()> {
- tokio::task::spawn_blocking(move || chmod(&path, mode)).await?
+ spawn_blocking(move || chmod(&path, mode)).await?
}
fn chown_sync(
@@ -129,53 +129,49 @@ impl FileSystem for RealFs {
uid: Option<u32>,
gid: Option<u32>,
) -> FsResult<()> {
- tokio::task::spawn_blocking(move || chown(&path, uid, gid)).await?
+ spawn_blocking(move || chown(&path, uid, gid)).await?
}
fn remove_sync(&self, path: &Path, recursive: bool) -> FsResult<()> {
remove(path, recursive)
}
async fn remove_async(&self, path: PathBuf, recursive: bool) -> FsResult<()> {
- tokio::task::spawn_blocking(move || remove(&path, recursive)).await?
+ spawn_blocking(move || remove(&path, recursive)).await?
}
fn copy_file_sync(&self, from: &Path, to: &Path) -> FsResult<()> {
copy_file(from, to)
}
async fn copy_file_async(&self, from: PathBuf, to: PathBuf) -> FsResult<()> {
- tokio::task::spawn_blocking(move || copy_file(&from, &to)).await?
+ spawn_blocking(move || copy_file(&from, &to)).await?
}
fn stat_sync(&self, path: &Path) -> FsResult<FsStat> {
stat(path).map(Into::into)
}
async fn stat_async(&self, path: PathBuf) -> FsResult<FsStat> {
- tokio::task::spawn_blocking(move || stat(&path))
- .await?
- .map(Into::into)
+ spawn_blocking(move || stat(&path)).await?.map(Into::into)
}
fn lstat_sync(&self, path: &Path) -> FsResult<FsStat> {
lstat(path).map(Into::into)
}
async fn lstat_async(&self, path: PathBuf) -> FsResult<FsStat> {
- tokio::task::spawn_blocking(move || lstat(&path))
- .await?
- .map(Into::into)
+ spawn_blocking(move || lstat(&path)).await?.map(Into::into)
}
fn realpath_sync(&self, path: &Path) -> FsResult<PathBuf> {
realpath(path)
}
async fn realpath_async(&self, path: PathBuf) -> FsResult<PathBuf> {
- tokio::task::spawn_blocking(move || realpath(&path)).await?
+ spawn_blocking(move || realpath(&path)).await?
}
fn read_dir_sync(&self, path: &Path) -> FsResult<Vec<FsDirEntry>> {
read_dir(path)
}
async fn read_dir_async(&self, path: PathBuf) -> FsResult<Vec<FsDirEntry>> {
- tokio::task::spawn_blocking(move || read_dir(&path)).await?
+ spawn_blocking(move || read_dir(&path)).await?
}
fn rename_sync(&self, oldpath: &Path, newpath: &Path) -> FsResult<()> {
@@ -186,7 +182,7 @@ impl FileSystem for RealFs {
oldpath: PathBuf,
newpath: PathBuf,
) -> FsResult<()> {
- tokio::task::spawn_blocking(move || fs::rename(oldpath, newpath))
+ spawn_blocking(move || fs::rename(oldpath, newpath))
.await?
.map_err(Into::into)
}
@@ -199,7 +195,7 @@ impl FileSystem for RealFs {
oldpath: PathBuf,
newpath: PathBuf,
) -> FsResult<()> {
- tokio::task::spawn_blocking(move || fs::hard_link(oldpath, newpath))
+ spawn_blocking(move || fs::hard_link(oldpath, newpath))
.await?
.map_err(Into::into)
}
@@ -218,15 +214,14 @@ impl FileSystem for RealFs {
newpath: PathBuf,
file_type: Option<FsFileType>,
) -> FsResult<()> {
- tokio::task::spawn_blocking(move || symlink(&oldpath, &newpath, file_type))
- .await?
+ spawn_blocking(move || symlink(&oldpath, &newpath, file_type)).await?
}
fn read_link_sync(&self, path: &Path) -> FsResult<PathBuf> {
fs::read_link(path).map_err(Into::into)
}
async fn read_link_async(&self, path: PathBuf) -> FsResult<PathBuf> {
- tokio::task::spawn_blocking(move || fs::read_link(path))
+ spawn_blocking(move || fs::read_link(path))
.await?
.map_err(Into::into)
}
@@ -235,7 +230,7 @@ impl FileSystem for RealFs {
truncate(path, len)
}
async fn truncate_async(&self, path: PathBuf, len: u64) -> FsResult<()> {
- tokio::task::spawn_blocking(move || truncate(&path, len)).await?
+ spawn_blocking(move || truncate(&path, len)).await?
}
fn utime_sync(
@@ -260,7 +255,7 @@ impl FileSystem for RealFs {
) -> FsResult<()> {
let atime = filetime::FileTime::from_unix_time(atime_secs, atime_nanos);
let mtime = filetime::FileTime::from_unix_time(mtime_secs, mtime_nanos);
- tokio::task::spawn_blocking(move || {
+ spawn_blocking(move || {
filetime::set_file_times(path, atime, mtime).map_err(Into::into)
})
.await?
@@ -289,7 +284,7 @@ impl FileSystem for RealFs {
options: OpenOptions,
data: Vec<u8>,
) -> FsResult<()> {
- tokio::task::spawn_blocking(move || {
+ spawn_blocking(move || {
let opts = open_options(options);
let mut file = opts.open(path)?;
#[cfg(unix)]
@@ -307,7 +302,7 @@ impl FileSystem for RealFs {
fs::read(path).map_err(Into::into)
}
async fn read_file_async(&self, path: PathBuf) -> FsResult<Vec<u8>> {
- tokio::task::spawn_blocking(move || fs::read(path))
+ spawn_blocking(move || fs::read(path))
.await?
.map_err(Into::into)
}
diff --git a/ext/http/http_next.rs b/ext/http/http_next.rs
index 12db29b1b..8b2f91be0 100644
--- a/ext/http/http_next.rs
+++ b/ext/http/http_next.rs
@@ -17,6 +17,8 @@ use cache_control::CacheControl;
use deno_core::error::AnyError;
use deno_core::futures::TryFutureExt;
use deno_core::op;
+use deno_core::task::spawn;
+use deno_core::task::JoinHandle;
use deno_core::AsyncRefCell;
use deno_core::AsyncResult;
use deno_core::ByteString;
@@ -68,9 +70,6 @@ use std::rc::Rc;
use tokio::io::AsyncReadExt;
use tokio::io::AsyncWriteExt;
-use tokio::task::spawn_local;
-use tokio::task::JoinHandle;
-
type Request = hyper1::Request<Incoming>;
type Response = hyper1::Response<ResponseBytes>;
@@ -262,7 +261,7 @@ pub fn op_http_upgrade_raw(
let (read_rx, write_tx) = tokio::io::split(read);
let (mut write_rx, mut read_tx) = tokio::io::split(write);
- spawn_local(async move {
+ spawn(async move {
let mut upgrade_stream = WebSocketUpgrade::<ResponseBytes>::default();
// Stage 2: Extract the Upgraded connection
@@ -285,7 +284,7 @@ pub fn op_http_upgrade_raw(
// Stage 3: Pump the data
let (mut upgraded_rx, mut upgraded_tx) = tokio::io::split(upgraded);
- spawn_local(async move {
+ spawn(async move {
let mut buf = [0; 1024];
loop {
let read = upgraded_rx.read(&mut buf).await?;
@@ -296,7 +295,7 @@ pub fn op_http_upgrade_raw(
}
Ok::<_, AnyError>(())
});
- spawn_local(async move {
+ spawn(async move {
let mut buf = [0; 1024];
loop {
let read = write_rx.read(&mut buf).await?;
@@ -792,11 +791,10 @@ fn serve_https(
cancel: Rc<CancelHandle>,
tx: tokio::sync::mpsc::Sender<u32>,
) -> JoinHandle<Result<(), AnyError>> {
- // TODO(mmastrac): This is faster if we can use tokio::spawn but then the send bounds get us
let svc = service_fn(move |req: Request| {
new_slab_future(req, request_info.clone(), tx.clone())
});
- spawn_local(
+ spawn(
async {
io.handshake().await?;
// If the client specifically negotiates a protocol, we will use it. If not, we'll auto-detect
@@ -820,11 +818,10 @@ fn serve_http(
cancel: Rc<CancelHandle>,
tx: tokio::sync::mpsc::Sender<u32>,
) -> JoinHandle<Result<(), AnyError>> {
- // TODO(mmastrac): This is faster if we can use tokio::spawn but then the send bounds get us
let svc = service_fn(move |req: Request| {
new_slab_future(req, request_info.clone(), tx.clone())
});
- spawn_local(serve_http2_autodetect(io, svc).try_or_cancel(cancel))
+ spawn(serve_http2_autodetect(io, svc).try_or_cancel(cancel))
}
fn serve_http_on<HTTP>(
@@ -916,7 +913,7 @@ where
let cancel_clone = resource.cancel_handle();
let listen_properties_clone: HttpListenProperties = listen_properties.clone();
- let handle = spawn_local(async move {
+ let handle = spawn(async move {
loop {
let conn = listener
.accept()
diff --git a/ext/http/lib.rs b/ext/http/lib.rs
index 21d3dc651..7a1a93f80 100644
--- a/ext/http/lib.rs
+++ b/ext/http/lib.rs
@@ -20,6 +20,7 @@ use deno_core::futures::FutureExt;
use deno_core::futures::StreamExt;
use deno_core::futures::TryFutureExt;
use deno_core::op;
+use deno_core::task::spawn;
use deno_core::AsyncRefCell;
use deno_core::AsyncResult;
use deno_core::BufView;
@@ -68,7 +69,6 @@ use std::task::Poll;
use tokio::io::AsyncRead;
use tokio::io::AsyncWrite;
use tokio::io::AsyncWriteExt;
-use tokio::task::spawn_local;
use crate::network_buffered_stream::NetworkBufferedStream;
use crate::reader_stream::ExternallyAbortableReaderStream;
@@ -184,7 +184,7 @@ impl HttpConnResource {
};
let (task_fut, closed_fut) = task_fut.remote_handle();
let closed_fut = closed_fut.shared();
- spawn_local(task_fut);
+ spawn(task_fut);
Self {
addr,
@@ -1005,7 +1005,7 @@ where
Fut::Output: 'static,
{
fn execute(&self, fut: Fut) {
- spawn_local(fut);
+ deno_core::task::spawn(fut);
}
}
@@ -1015,7 +1015,7 @@ where
Fut::Output: 'static,
{
fn execute(&self, fut: Fut) {
- spawn_local(fut);
+ deno_core::task::spawn(fut);
}
}
diff --git a/ext/io/lib.rs b/ext/io/lib.rs
index 49e4ab714..6dec7c3a7 100644
--- a/ext/io/lib.rs
+++ b/ext/io/lib.rs
@@ -2,6 +2,7 @@
use deno_core::error::AnyError;
use deno_core::op;
+use deno_core::task::spawn_blocking;
use deno_core::AsyncMutFuture;
use deno_core::AsyncRefCell;
use deno_core::AsyncResult;
@@ -350,7 +351,7 @@ impl StdFileResourceInner {
}
}
};
- let (cell_value, result) = tokio::task::spawn_blocking(move || {
+ let (cell_value, result) = spawn_blocking(move || {
let result = action(&mut cell_value);
(cell_value, result)
})
@@ -372,7 +373,7 @@ impl StdFileResourceInner {
// we want to restrict this to one async action at a time
let _permit = self.cell_async_task_queue.acquire().await;
- tokio::task::spawn_blocking(action).await.unwrap()
+ spawn_blocking(action).await.unwrap()
}
}
diff --git a/ext/net/ops_tls.rs b/ext/net/ops_tls.rs
index b9b37b328..7f451d0a8 100644
--- a/ext/net/ops_tls.rs
+++ b/ext/net/ops_tls.rs
@@ -26,6 +26,7 @@ use deno_core::futures::task::Waker;
use deno_core::op;
use deno_core::parking_lot::Mutex;
+use deno_core::task::spawn;
use deno_core::AsyncRefCell;
use deno_core::AsyncResult;
use deno_core::ByteString;
@@ -74,7 +75,6 @@ use tokio::io::AsyncWriteExt;
use tokio::io::ReadBuf;
use tokio::net::TcpListener;
use tokio::net::TcpStream;
-use tokio::task::spawn_local;
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
enum Flow {
@@ -224,9 +224,9 @@ impl Drop for TlsStream {
let use_linger_task = inner.poll_close(&mut cx).is_pending();
if use_linger_task {
- spawn_local(poll_fn(move |cx| inner.poll_close(cx)));
+ spawn(poll_fn(move |cx| inner.poll_close(cx)));
} else if cfg!(debug_assertions) {
- spawn_local(async {}); // Spawn dummy task to detect missing LocalSet.
+ spawn(async {}); // Spawn dummy task to detect missing runtime.
}
}
}
diff --git a/ext/node/ops/crypto/mod.rs b/ext/node/ops/crypto/mod.rs
index 9e1a3da98..0f8feb2a9 100644
--- a/ext/node/ops/crypto/mod.rs
+++ b/ext/node/ops/crypto/mod.rs
@@ -4,6 +4,7 @@ use deno_core::error::type_error;
use deno_core::error::AnyError;
use deno_core::op;
use deno_core::serde_v8;
+use deno_core::task::spawn_blocking;
use deno_core::OpState;
use deno_core::ResourceId;
use deno_core::StringOrBuffer;
@@ -57,12 +58,7 @@ pub async fn op_node_check_prime_async(
checks: usize,
) -> Result<bool, AnyError> {
// TODO(@littledivy): use rayon for CPU-bound tasks
- Ok(
- tokio::task::spawn_blocking(move || {
- primes::is_probably_prime(&num, checks)
- })
- .await?,
- )
+ Ok(spawn_blocking(move || primes::is_probably_prime(&num, checks)).await?)
}
#[op]
@@ -74,10 +70,8 @@ pub fn op_node_check_prime_bytes_async(
// TODO(@littledivy): use rayon for CPU-bound tasks
Ok(async move {
Ok(
- tokio::task::spawn_blocking(move || {
- primes::is_probably_prime(&candidate, checks)
- })
- .await?,
+ spawn_blocking(move || primes::is_probably_prime(&candidate, checks))
+ .await?,
)
})
}
@@ -462,7 +456,7 @@ pub async fn op_node_pbkdf2_async(
digest: String,
keylen: usize,
) -> Result<ZeroCopyBuf, AnyError> {
- tokio::task::spawn_blocking(move || {
+ spawn_blocking(move || {
let mut derived_key = vec![0; keylen];
pbkdf2_sync(&password, &salt, iterations, &digest, &mut derived_key)
.map(|_| derived_key.into())
@@ -477,7 +471,7 @@ pub fn op_node_generate_secret(buf: &mut [u8]) {
#[op]
pub async fn op_node_generate_secret_async(len: i32) -> ZeroCopyBuf {
- tokio::task::spawn_blocking(move || {
+ spawn_blocking(move || {
let mut buf = vec![0u8; len as usize];
rand::thread_rng().fill(&mut buf[..]);
buf.into()
@@ -535,7 +529,7 @@ pub async fn op_node_hkdf_async(
info: ZeroCopyBuf,
okm_len: usize,
) -> Result<ZeroCopyBuf, AnyError> {
- tokio::task::spawn_blocking(move || {
+ spawn_blocking(move || {
let mut okm = vec![0u8; okm_len];
hkdf_sync(&hash, &ikm, &salt, &info, &mut okm)?;
Ok(okm.into())
@@ -578,10 +572,7 @@ pub async fn op_node_generate_rsa_async(
modulus_length: usize,
public_exponent: usize,
) -> Result<(ZeroCopyBuf, ZeroCopyBuf), AnyError> {
- tokio::task::spawn_blocking(move || {
- generate_rsa(modulus_length, public_exponent)
- })
- .await?
+ spawn_blocking(move || generate_rsa(modulus_length, public_exponent)).await?
}
fn dsa_generate(
@@ -635,10 +626,7 @@ pub async fn op_node_dsa_generate_async(
modulus_length: usize,
divisor_length: usize,
) -> Result<(ZeroCopyBuf, ZeroCopyBuf), AnyError> {
- tokio::task::spawn_blocking(move || {
- dsa_generate(modulus_length, divisor_length)
- })
- .await?
+ spawn_blocking(move || dsa_generate(modulus_length, divisor_length)).await?
}
fn ec_generate(
@@ -677,7 +665,7 @@ pub fn op_node_ec_generate(
pub async fn op_node_ec_generate_async(
named_curve: String,
) -> Result<(ZeroCopyBuf, ZeroCopyBuf), AnyError> {
- tokio::task::spawn_blocking(move || ec_generate(&named_curve)).await?
+ spawn_blocking(move || ec_generate(&named_curve)).await?
}
fn ed25519_generate() -> Result<(ZeroCopyBuf, ZeroCopyBuf), AnyError> {
@@ -704,7 +692,7 @@ pub fn op_node_ed25519_generate() -> Result<(ZeroCopyBuf, ZeroCopyBuf), AnyError
#[op]
pub async fn op_node_ed25519_generate_async(
) -> Result<(ZeroCopyBuf, ZeroCopyBuf), AnyError> {
- tokio::task::spawn_blocking(ed25519_generate).await?
+ spawn_blocking(ed25519_generate).await?
}
fn x25519_generate() -> Result<(ZeroCopyBuf, ZeroCopyBuf), AnyError> {
@@ -739,7 +727,7 @@ pub fn op_node_x25519_generate() -> Result<(ZeroCopyBuf, ZeroCopyBuf), AnyError>
#[op]
pub async fn op_node_x25519_generate_async(
) -> Result<(ZeroCopyBuf, ZeroCopyBuf), AnyError> {
- tokio::task::spawn_blocking(x25519_generate).await?
+ spawn_blocking(x25519_generate).await?
}
fn dh_generate_group(
@@ -772,7 +760,7 @@ pub fn op_node_dh_generate_group(
pub async fn op_node_dh_generate_group_async(
group_name: String,
) -> Result<(ZeroCopyBuf, ZeroCopyBuf), AnyError> {
- tokio::task::spawn_blocking(move || dh_generate_group(&group_name)).await?
+ spawn_blocking(move || dh_generate_group(&group_name)).await?
}
fn dh_generate(
@@ -806,10 +794,8 @@ pub async fn op_node_dh_generate_async(
prime_len: usize,
generator: usize,
) -> Result<(ZeroCopyBuf, ZeroCopyBuf), AnyError> {
- tokio::task::spawn_blocking(move || {
- dh_generate(prime.as_deref(), prime_len, generator)
- })
- .await?
+ spawn_blocking(move || dh_generate(prime.as_deref(), prime_len, generator))
+ .await?
}
#[op]
@@ -885,7 +871,7 @@ pub async fn op_node_scrypt_async(
parallelization: u32,
maxmem: u32,
) -> Result<ZeroCopyBuf, AnyError> {
- tokio::task::spawn_blocking(move || {
+ spawn_blocking(move || {
let mut output_buffer = vec![0u8; keylen as usize];
let res = scrypt(
password,
@@ -1081,5 +1067,5 @@ pub fn op_node_gen_prime(size: usize) -> ZeroCopyBuf {
pub async fn op_node_gen_prime_async(
size: usize,
) -> Result<ZeroCopyBuf, AnyError> {
- Ok(tokio::task::spawn_blocking(move || gen_prime(size)).await?)
+ Ok(spawn_blocking(move || gen_prime(size)).await?)
}
diff --git a/ext/websocket/lib.rs b/ext/websocket/lib.rs
index e03a13789..a002b774c 100644
--- a/ext/websocket/lib.rs
+++ b/ext/websocket/lib.rs
@@ -591,6 +591,6 @@ where
Fut::Output: 'static,
{
fn execute(&self, fut: Fut) {
- tokio::task::spawn_local(fut);
+ deno_core::task::spawn(fut);
}
}