Skip to content

Commit

Permalink
rebase fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
afinch7 committed Nov 18, 2019
1 parent 811d020 commit 51910ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
22 changes: 9 additions & 13 deletions cli/ops/native_plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,13 @@ use dlopen::symbor::Library;
use std::collections::HashMap;
use std::ffi::OsStr;
use std::sync::Arc;
use std::sync::Mutex;

pub fn init(
i: &mut Isolate,
s: &ThreadSafeState,
isolate_arc: Arc<Mutex<deno::Isolate>>,
) {
let isolate_arc_ = isolate_arc.clone();
pub fn init(i: &mut Isolate, s: &ThreadSafeState, r: Arc<deno::OpRegistry>) {
let r_ = r.clone();
i.register_op(
"open_native_plugin",
s.core_op(json_op(s.stateful_op(move |state, args, zero_copy| {
op_open_native_plugin(&isolate_arc_, state, args, zero_copy)
op_open_native_plugin(&r_, state, args, zero_copy)
}))),
);
}
Expand All @@ -37,7 +32,7 @@ struct NativePluginResource {
impl Resource for NativePluginResource {}

struct InitContext {
isolate: Arc<Mutex<deno::Isolate>>,
registry: Arc<deno::OpRegistry>,
plugin_rid: ResourceId,
ops: Vec<(String, OpId)>,
}
Expand All @@ -48,8 +43,9 @@ impl PluginInitContext for InitContext {
name: &str,
op: Box<dyn Fn(&[u8], Option<PinnedBuf>) -> CoreOp + Send + Sync + 'static>,
) -> OpId {
let mut i = self.isolate.lock().unwrap();
let opid = i.register_op(&format!("{}_{}", self.plugin_rid, name), op);
let opid = self
.registry
.register(&format!("{}_{}", self.plugin_rid, name), op);
self.ops.push((name.to_string(), opid));
opid
}
Expand All @@ -62,7 +58,7 @@ struct OpenNativePluginArgs {
}

pub fn op_open_native_plugin(
isolate: &Arc<Mutex<Isolate>>,
registry: &Arc<deno::OpRegistry>,
state: &ThreadSafeState,
args: Value,
_zero_copy: Option<PinnedBuf>,
Expand All @@ -87,7 +83,7 @@ pub fn op_open_native_plugin(
.symbol::<PluginInitFn>("native_plugin_init")
}?;
let mut init_context = InitContext {
isolate: isolate.clone(),
registry: registry.clone(),
plugin_rid: rid,
ops: Vec::new(),
};
Expand Down
3 changes: 2 additions & 1 deletion cli/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ impl Worker {
let isolate = Arc::new(Mutex::new(deno::Isolate::new(startup_data, false)));
{
let mut i = isolate.lock().unwrap();
let op_registry = i.op_registry.clone();

ops::compiler::init(&mut i, &state);
ops::errors::init(&mut i, &state);
ops::fetch::init(&mut i, &state);
ops::files::init(&mut i, &state);
ops::fs::init(&mut i, &state);
ops::io::init(&mut i, &state);
ops::native_plugins::init(&mut i, &state, isolate.clone());
ops::native_plugins::init(&mut i, &state, op_registry);
ops::net::init(&mut i, &state);
ops::tls::init(&mut i, &state);
ops::os::init(&mut i, &state);
Expand Down

0 comments on commit 51910ee

Please sign in to comment.