Last active
October 23, 2015 12:17
-
-
Save Ms2ger/d21f605b0636139f4fb9 to your computer and use it in GitHub Desktop.
jsapi threading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "test" | |
version = "0.1.0" | |
authors = ["Ms2ger <[email protected]>"] | |
[[bin]] | |
path = "main.rs" | |
name = "test" | |
[dependencies.js] | |
git = "https://github.com/servo/rust-mozjs" | |
features = ["debugmozjs"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate js; | |
use js::jsapi::{JS_Init, JS_NewRuntime}; | |
use std::thread; | |
use std::ptr; | |
fn create_runtime() { | |
unsafe { | |
JS_NewRuntime(0x2000000, 0x100000, ptr::null_mut()); | |
} | |
println!("Created"); | |
} | |
fn main() { | |
println!("Hello, world!"); | |
assert!(unsafe { JS_Init() }); | |
let x = thread::spawn(create_runtime); | |
let y = thread::spawn(create_runtime); | |
let z = thread::spawn(create_runtime); | |
x.join().unwrap(); | |
y.join().unwrap(); | |
z.join().unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment