summaryrefslogtreecommitdiff
path: root/cli/worker.rs
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-04-23 18:58:00 -0400
committerGitHub <noreply@github.com>2019-04-23 18:58:00 -0400
commitd68b44b6b2fad6c321aa01a039030bb98c5be88d (patch)
treeece2a6c7d4787a697aa9ba10cbf643d02d713294 /cli/worker.rs
parent675919e915650cd1c88a1cdb4f67310133b8a05e (diff)
core: make Isolate concrete, remove Dispatch trait (#2183)
Op dispatch is now dynamically dispatched, so slightly less efficient. The immeasurable perf hit is a reasonable trade for the API simplicity that is gained here.
Diffstat (limited to 'cli/worker.rs')
-rw-r--r--cli/worker.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/cli/worker.rs b/cli/worker.rs
index 408bae1c6..8b420cef6 100644
--- a/cli/worker.rs
+++ b/cli/worker.rs
@@ -9,6 +9,7 @@ use crate::msg;
use crate::state::ThreadSafeState;
use crate::tokio_util;
use deno;
+use deno::Config;
use deno::JSError;
use deno::Loader;
use deno::StartupData;
@@ -21,7 +22,7 @@ use url::Url;
/// Wraps deno::Isolate to provide source maps, ops for the CLI, and
/// high-level module loading
pub struct Worker {
- inner: deno::Isolate<ThreadSafeState>,
+ inner: deno::Isolate,
pub modules: deno::Modules,
pub state: ThreadSafeState,
}
@@ -33,8 +34,12 @@ impl Worker {
state: ThreadSafeState,
) -> Worker {
let state_ = state.clone();
+ let mut config = Config::default();
+ config.dispatch(move |control_buf, zero_copy_buf| {
+ state_.dispatch(control_buf, zero_copy_buf)
+ });
Self {
- inner: deno::Isolate::new(startup_data, state_),
+ inner: deno::Isolate::new(startup_data, config),
modules: deno::Modules::new(),
state,
}
@@ -154,7 +159,6 @@ pub fn root_specifier_to_url(
}
impl Loader for Worker {
- type Dispatch = ThreadSafeState;
type Error = DenoError;
fn resolve(specifier: &str, referrer: &str) -> Result<String, Self::Error> {
@@ -187,7 +191,7 @@ impl Loader for Worker {
fn isolate_and_modules<'a: 'b + 'c, 'b, 'c>(
&'a mut self,
- ) -> (&'b mut deno::Isolate<Self::Dispatch>, &'c mut deno::Modules) {
+ ) -> (&'b mut deno::Isolate, &'c mut deno::Modules) {
(&mut self.inner, &mut self.modules)
}
}