perf: move Deno.writeTextFile and like functions to Rust (#14221)

Co-authored-by: Luca Casonato <hello@lcas.dev>
This commit is contained in:
David Sherret 2022-04-18 18:00:14 -04:00 committed by GitHub
parent ca3b20df3c
commit a64e63c361
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 222 additions and 138 deletions

View file

@ -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")
}