mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
Add threading spec.
Thanks to @dturnbull for providing these cases in #98.
This commit is contained in:
parent
1ce63c508c
commit
fce4553353
1 changed files with 24 additions and 0 deletions
24
spec/threading_spec.rb
Normal file
24
spec/threading_spec.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe "using v8 from multiple threads" do
|
||||
|
||||
it "creates contexts from within threads" do
|
||||
10.times.collect do
|
||||
Thread.new do
|
||||
V8::Context.new
|
||||
end
|
||||
end.each {|t| t.join}
|
||||
V8::Context.new
|
||||
end
|
||||
|
||||
it "executes codes on multiple threads simultaneously" do
|
||||
5.times.collect{V8::Context.new}.collect do |ctx|
|
||||
Thread.new do
|
||||
ctx['x'] = 99
|
||||
while ctx['x'] > 0
|
||||
ctx.eval 'for (i=10000;i;i--){};--x'
|
||||
end
|
||||
end
|
||||
end.each {|t| t.join}
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue