diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2020-04-19 23:54:46 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-19 23:54:46 -0400 |
commit | c1ec042a0011eeba2480b892a335ca7804c59180 (patch) | |
tree | 02d9595a3a6be9fb646171be29f59a3c0f74f12f /cli/ops/plugins.rs | |
parent | 4e3532fe7b61a1050b00611081cc83af8b02de70 (diff) |
Modify op dispatcher to include &mut Isolate argument (#4821)
- Removes unnecessary RwLock and Rc around the op registry table
- Preparation to move resource_table to deno_core::Isolate.
- Towards #3453, #4222
Diffstat (limited to 'cli/ops/plugins.rs')
-rw-r--r-- | cli/ops/plugins.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/cli/ops/plugins.rs b/cli/ops/plugins.rs index 816c7ebb4..c0dffc90f 100644 --- a/cli/ops/plugins.rs +++ b/cli/ops/plugins.rs @@ -3,20 +3,21 @@ use crate::fs as deno_fs; use crate::op_error::OpError; use crate::ops::json_op; use crate::state::State; -use deno_core::*; +use deno_core::Isolate; +use deno_core::OpDispatcher; +use deno_core::OpId; +use deno_core::PluginInitContext; +use deno_core::PluginInitFn; +use deno_core::ZeroCopyBuf; use dlopen::symbor::Library; use std::collections::HashMap; use std::ffi::OsStr; use std::path::Path; -use std::rc::Rc; -pub fn init(i: &mut Isolate, s: &State, r: Rc<deno_core::OpRegistry>) { - let r_ = r; +pub fn init(i: &mut Isolate, s: &State) { i.register_op( "op_open_plugin", - s.core_op(json_op(s.stateful_op(move |state, args, zero_copy| { - op_open_plugin(&r_, state, args, zero_copy) - }))), + s.core_op(json_op(s.stateful_op2(op_open_plugin))), ); } @@ -52,7 +53,7 @@ struct OpenPluginArgs { } pub fn op_open_plugin( - registry: &Rc<deno_core::OpRegistry>, + isolate: &mut deno_core::Isolate, state: &State, args: Value, _zero_copy: Option<ZeroCopyBuf>, @@ -91,8 +92,8 @@ pub fn op_open_plugin( // The inclusion of prefix and rid is designed to avoid any // op name collision beyond the bound of a single loaded // plugin instance. - let op_id = registry - .register(&format!("plugin_{}_{}", rid, op.0), state.core_op(op.1)); + let op_id = isolate + .register_op(&format!("plugin_{}_{}", rid, op.0), state.core_op(op.1)); plugin_resource.ops.insert(op.0, op_id); } |