summaryrefslogtreecommitdiff
path: root/core/modules.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 /core/modules.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 'core/modules.rs')
-rw-r--r--core/modules.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/core/modules.rs b/core/modules.rs
index 435255856..1efab663b 100644
--- a/core/modules.rs
+++ b/core/modules.rs
@@ -35,7 +35,6 @@ pub type SourceCodeInfoFuture<E> =
dyn Future<Item = SourceCodeInfo, Error = E> + Send;
pub trait Loader {
- type Dispatch: crate::isolate::Dispatch;
type Error: std::error::Error + 'static;
/// Returns an absolute URL.
@@ -49,9 +48,9 @@ pub trait Loader {
fn isolate_and_modules<'a: 'b + 'c, 'b, 'c>(
&'a mut self,
- ) -> (&'b mut Isolate<Self::Dispatch>, &'c mut Modules);
+ ) -> (&'b mut Isolate, &'c mut Modules);
- fn isolate<'a: 'b, 'b>(&'a mut self) -> &'b mut Isolate<Self::Dispatch> {
+ fn isolate<'a: 'b, 'b>(&'a mut self) -> &'b mut Isolate {
let (isolate, _) = self.isolate_and_modules();
isolate
}
@@ -536,14 +535,14 @@ mod tests {
struct MockLoader {
pub loads: Vec<String>,
- pub isolate: Isolate<TestDispatch>,
+ pub isolate: Isolate,
pub modules: Modules,
}
impl MockLoader {
fn new() -> Self {
let modules = Modules::new();
- let isolate = TestDispatch::setup(TestDispatchMode::AsyncImmediate);
+ let (isolate, _dispatch_count) = setup(Mode::AsyncImmediate);
Self {
loads: Vec::new(),
isolate,
@@ -619,7 +618,6 @@ mod tests {
}
impl Loader for MockLoader {
- type Dispatch = TestDispatch;
type Error = MockError;
fn resolve(specifier: &str, referrer: &str) -> Result<String, Self::Error> {
@@ -659,7 +657,7 @@ mod tests {
fn isolate_and_modules<'a: 'b + 'c, 'b, 'c>(
&'a mut self,
- ) -> (&'b mut Isolate<Self::Dispatch>, &'c mut Modules) {
+ ) -> (&'b mut Isolate, &'c mut Modules) {
(&mut self.isolate, &mut self.modules)
}
}