summaryrefslogtreecommitdiff
path: root/core/async_cell.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-12-16 17:14:12 +0100
committerGitHub <noreply@github.com>2020-12-16 17:14:12 +0100
commit6984b63f2f3c8d0819fe2dced8252a81f3400ae7 (patch)
tree5201bc962f913927409ae2770aca48ffa3aaaa34 /core/async_cell.rs
parent9fe26f8ca189ac81d9c20c454b9dbfa5e1011c3f (diff)
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.
Diffstat (limited to 'core/async_cell.rs')
-rw-r--r--core/async_cell.rs15
1 files changed, 15 insertions, 0 deletions
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<T: 'static> AsyncRefCell<T> {
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<T> Debug for AsyncRefCell<T> {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ write!(f, "AsyncRefCell<{}>", type_name::<T>())
+ }
}
impl<T: Default + 'static> Default for AsyncRefCell<T> {