From a64e63c3614b98aa2b51fb6b7ef4e30251e03111 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 18 Apr 2022 18:00:14 -0400 Subject: perf: move Deno.writeTextFile and like functions to Rust (#14221) Co-authored-by: Luca Casonato --- core/async_cancel.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'core/async_cancel.rs') diff --git a/core/async_cancel.rs b/core/async_cancel.rs index e8f25136c..cf338174d 100644 --- a/core/async_cancel.rs +++ b/core/async_cancel.rs @@ -1,6 +1,7 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. use crate::RcLike; +use crate::Resource; use futures::future::FusedFuture; use futures::future::Future; use futures::future::TryFuture; @@ -8,6 +9,7 @@ use futures::task::Context; use futures::task::Poll; use pin_project::pin_project; use std::any::type_name; +use std::borrow::Cow; use std::error::Error; use std::fmt; use std::fmt::Display; @@ -84,6 +86,16 @@ impl FusedFuture for Cancelable { } } +impl Resource for CancelHandle { + fn name(&self) -> Cow { + "cancellation".into() + } + + fn close(self: Rc) { + self.cancel(); + } +} + #[pin_project(project = TryCancelableProjection)] #[derive(Debug)] pub struct TryCancelable { -- cgit v1.2.3