Skip to content
Permalink
Browse files

Add Isolate::shared_init

  • Loading branch information...
ry committed Mar 15, 2019
1 parent e532a18 commit bf503c68508da4eb69a2131558aa5c3e96778ad6
Showing with 17 additions and 64 deletions.
  1. +11 −0 core/isolate.rs
  2. +0 −49 core/shared.rs
  3. +6 −8 core/shared_queue.rs
  4. +0 −7 core/test_util.rs
@@ -114,6 +114,11 @@ impl<B: Behavior> Isolate<B> {
}
}

/// Executes a bit of built-in JavaScript to provide Deno._sharedQueue.
pub fn shared_init(&self) {
js_check(self.execute("shared_queue.js", include_str!("shared_queue.js")));
}

extern "C" fn pre_dispatch(
user_data: *mut c_void,
control_argv0: deno_buf,
@@ -390,6 +395,12 @@ impl<B: Behavior> Future for Isolate<B> {
}
}

pub fn js_check(r: Result<(), JSError>) {
if let Err(e) = r {
panic!(e.to_string());
}
}

#[cfg(test)]
mod tests {
use super::*;

This file was deleted.

Oops, something went wrong.
@@ -146,6 +146,11 @@ impl SharedQueue {
#[cfg(test)]
mod tests {
use super::*;
use crate::isolate::js_check;
use crate::isolate::Isolate;
use crate::test_util::*;
use futures::Async;
use futures::Future;

#[test]
fn basic() {
@@ -217,18 +222,11 @@ mod tests {
assert!(!q.push(alloc_buf(1)));
}

use crate::isolate::Isolate;
use crate::test_util::*;
use futures::Async;
use futures::Future;

#[test]
fn test_js() {
let behavior = TestBehavior::new();
let mut isolate = Isolate::new(behavior);
js_check(
isolate.execute("shared_queue.js", include_str!("shared_queue.js")),
);
isolate.shared_init();
js_check(
isolate
.execute("shared_queue_test.js", include_str!("shared_queue_test.js")),
@@ -1,16 +1,9 @@
use crate::isolate::Behavior;
use crate::isolate::Op;
use crate::js_errors::JSError;
use crate::libdeno::deno_buf;
use crate::libdeno::deno_mod;
use std::collections::HashMap;

pub fn js_check(r: Result<(), JSError>) {
if let Err(e) = r {
panic!(e.to_string());
}
}

pub struct TestBehavior {
pub recv_count: usize,
pub resolve_count: usize,

0 comments on commit bf503c6

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.