1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00
therubyracer/spec/threading_spec.rb
Charles Lowell fce4553353 Add threading spec.
Thanks to @dturnbull for providing these cases in
#98.
2012-06-19 04:50:36 -05:00

24 lines
No EOL
534 B
Ruby

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