Permalink
Browse files

don't run thread specs as part of the CI build.

  • Loading branch information...
1 parent ea061df commit 3c6c0c5a5d7776efc8598f38cd794d8aabc19ae6 @cowboyd committed Jun 19, 2012
Showing with 30 additions and 2 deletions.
  1. +1 −1 Rakefile
  2. +29 −1 spec/threading_spec.rb
View
2 Rakefile
@@ -16,7 +16,7 @@ end
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |task|
- task.rspec_opts = '--tag ~memory'
+ task.rspec_opts = '--tag ~memory --tag ~threads'
end
task :sanity => [:clean, :compile] do
View
30 spec/threading_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe "using v8 from multiple threads" do
+describe "using v8 from multiple threads", :threads => true do
it "creates contexts from within threads" do
10.times.collect do
@@ -21,4 +21,32 @@
end
end.each {|t| t.join}
end
+
+ it "can access the current thread id" do
+ V8::C::Locker() do
+ V8::C::V8::GetCurrentThreadId().should_not be_nil
+ end
+ end
+
+ it "can pre-empt a running JavaScript thread" do
+ pending "need to release the GIL while executing V8 code"
+ begin
+ V8::C::Locker::StartPreemption(2)
+ thread_id = nil
+ Thread.new do
+ loop until thread_id
+ puts "thread id: #{thread_id}"
+ V8::C::V8::TerminateExecution(thread_id)
+ end
+ Thread.new do
+ V8::C::Locker() do
+ thread_id = V8::C::V8::GetCurrentThreadId()
+ V8::Context.new {|cxt| cxt.eval('while (true) {}')}
+ end
+ end
+ V8::C::V8::TerminateExecution(thread_id)
+ ensure
+ V8::C::Locker::StopPreemption()
+ end
+ end
end

0 comments on commit 3c6c0c5

Please sign in to comment.