Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 3c6c0c5a5d7776efc8598f38cd794d8aabc19ae6 1 parent ea061df
Charles Lowell authored
2  Rakefile
@@ -16,7 +16,7 @@ end
16 16
 
17 17
 require 'rspec/core/rake_task'
18 18
 RSpec::Core::RakeTask.new(:spec) do |task|
19  
-  task.rspec_opts = '--tag ~memory'
  19
+  task.rspec_opts = '--tag ~memory --tag ~threads'
20 20
 end
21 21
 
22 22
 task :sanity => [:clean, :compile] do
30  spec/threading_spec.rb
... ...
@@ -1,6 +1,6 @@
1 1
 require 'spec_helper'
2 2
 
3  
-describe "using v8 from multiple threads" do
  3
+describe "using v8 from multiple threads", :threads => true do
4 4
 
5 5
   it "creates contexts from within threads" do
6 6
     10.times.collect do
@@ -21,4 +21,32 @@
21 21
       end
22 22
     end.each {|t| t.join}
23 23
   end
  24
+
  25
+  it "can access the current thread id" do
  26
+    V8::C::Locker() do
  27
+      V8::C::V8::GetCurrentThreadId().should_not be_nil
  28
+    end
  29
+  end
  30
+
  31
+  it "can pre-empt a running JavaScript thread" do
  32
+    pending "need to release the GIL while executing V8 code"
  33
+    begin
  34
+      V8::C::Locker::StartPreemption(2)
  35
+      thread_id = nil
  36
+      Thread.new do
  37
+        loop until thread_id
  38
+        puts "thread id: #{thread_id}"
  39
+        V8::C::V8::TerminateExecution(thread_id)
  40
+      end
  41
+      Thread.new do
  42
+        V8::C::Locker() do
  43
+          thread_id = V8::C::V8::GetCurrentThreadId()
  44
+          V8::Context.new {|cxt| cxt.eval('while (true) {}')}
  45
+        end
  46
+      end
  47
+      V8::C::V8::TerminateExecution(thread_id)
  48
+    ensure
  49
+      V8::C::Locker::StopPreemption()
  50
+    end
  51
+  end
24 52
 end

0 notes on commit 3c6c0c5

Please sign in to comment.
Something went wrong with that request. Please try again.