From d68b44b6b2fad6c321aa01a039030bb98c5be88d Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 23 Apr 2019 18:58:00 -0400 Subject: 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. --- core/modules.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'core/modules.rs') 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 = dyn Future + 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, &'c mut Modules); + ) -> (&'b mut Isolate, &'c mut Modules); - fn isolate<'a: 'b, 'b>(&'a mut self) -> &'b mut Isolate { + 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, - pub isolate: Isolate, + 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 { @@ -659,7 +657,7 @@ mod tests { fn isolate_and_modules<'a: 'b + 'c, 'b, 'c>( &'a mut self, - ) -> (&'b mut Isolate, &'c mut Modules) { + ) -> (&'b mut Isolate, &'c mut Modules) { (&mut self.isolate, &mut self.modules) } } -- cgit v1.2.3