summaryrefslogtreecommitdiff
path: root/runtime/ops/plugin.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 /runtime/ops/plugin.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 'runtime/ops/plugin.rs')
-rw-r--r--runtime/ops/plugin.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/runtime/ops/plugin.rs b/runtime/ops/plugin.rs
index 1f3669b6f..953d6f7d2 100644
--- a/runtime/ops/plugin.rs
+++ b/runtime/ops/plugin.rs
@@ -14,9 +14,11 @@ use deno_core::Op;
use deno_core::OpAsyncFuture;
use deno_core::OpId;
use deno_core::OpState;
+use deno_core::Resource;
use deno_core::ZeroCopyBuf;
use dlopen::symbor::Library;
use serde::Deserialize;
+use std::borrow::Cow;
use std::cell::RefCell;
use std::path::PathBuf;
use std::pin::Pin;
@@ -53,9 +55,7 @@ pub fn op_open_plugin(
let rid;
let deno_plugin_init;
{
- rid = state
- .resource_table
- .add("plugin", Box::new(plugin_resource));
+ rid = state.resource_table.add(plugin_resource);
deno_plugin_init = *unsafe {
state
.resource_table
@@ -77,6 +77,12 @@ struct PluginResource {
lib: Rc<Library>,
}
+impl Resource for PluginResource {
+ fn name(&self) -> Cow<str> {
+ "plugin".into()
+ }
+}
+
impl PluginResource {
fn new(lib: &Rc<Library>) -> Self {
Self { lib: lib.clone() }