From 6984b63f2f3c8d0819fe2dced8252a81f3400ae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 16 Dec 2020 17:14:12 +0100 Subject: refactor: rewrite ops to use ResourceTable2 (#8512) This commit migrates all ops to use new resource table and "AsyncRefCell". Old implementation of resource table was completely removed and all code referencing it was updated to use new system. --- core/async_cell.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'core/async_cell.rs') diff --git a/core/async_cell.rs b/core/async_cell.rs index d11b83932..cd6c51682 100644 --- a/core/async_cell.rs +++ b/core/async_cell.rs @@ -1,10 +1,14 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +use std::any::type_name; use std::any::Any; use std::borrow::Borrow; use std::cell::Cell; use std::cell::UnsafeCell; use std::collections::VecDeque; +use std::fmt; +use std::fmt::Debug; +use std::fmt::Formatter; use std::ops::Deref; use std::rc::Rc; @@ -45,6 +49,17 @@ impl AsyncRefCell { pub fn as_ptr(&self) -> *mut T { self.value.get() } + + pub fn into_inner(self) -> T { + assert!(self.borrow_count.get().is_empty()); + self.value.into_inner() + } +} + +impl Debug for AsyncRefCell { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + write!(f, "AsyncRefCell<{}>", type_name::()) + } } impl Default for AsyncRefCell { -- cgit v1.2.3