diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-04-18 18:00:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-18 18:00:14 -0400 |
commit | a64e63c3614b98aa2b51fb6b7ef4e30251e03111 (patch) | |
tree | be380bdc2d7c61126c594708aa97cacede9b6316 /ext/web | |
parent | ca3b20df3c270f1bf5f1a7980c083c22a590420d (diff) |
perf: move Deno.writeTextFile and like functions to Rust (#14221)
Co-authored-by: Luca Casonato <hello@lcas.dev>
Diffstat (limited to 'ext/web')
-rw-r--r-- | ext/web/lib.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/ext/web/lib.rs b/ext/web/lib.rs index 423e53c51..d14a4a5d5 100644 --- a/ext/web/lib.rs +++ b/ext/web/lib.rs @@ -12,6 +12,7 @@ use deno_core::include_js_files; use deno_core::op; use deno_core::url::Url; use deno_core::ByteString; +use deno_core::CancelHandle; use deno_core::Extension; use deno_core::OpState; use deno_core::Resource; @@ -107,6 +108,7 @@ pub fn init<P: TimersPermission + 'static>( compression::op_compression_finish::decl(), op_now::decl::<P>(), op_timer_handle::decl(), + op_cancel_handle::decl(), op_sleep::decl(), op_sleep_sync::decl::<P>(), ]) @@ -352,6 +354,13 @@ fn op_encoding_encode_into( }) } +/// Creates a [`CancelHandle`] resource that can be used to cancel invocations of certain ops. +#[op] +pub fn op_cancel_handle(state: &mut OpState) -> Result<ResourceId, AnyError> { + let rid = state.resource_table.add(CancelHandle::new()); + Ok(rid) +} + pub fn get_declaration() -> PathBuf { PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_web.d.ts") } |