summaryrefslogtreecommitdiff
path: root/spec/ruby/optional/capi/thread_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/optional/capi/thread_spec.rb')
-rw-r--r--spec/ruby/optional/capi/thread_spec.rb38
1 files changed, 23 insertions, 15 deletions
diff --git a/spec/ruby/optional/capi/thread_spec.rb b/spec/ruby/optional/capi/thread_spec.rb
index 30e29681eb..af641f0564 100644
--- a/spec/ruby/optional/capi/thread_spec.rb
+++ b/spec/ruby/optional/capi/thread_spec.rb
@@ -101,6 +101,16 @@ describe "C-API Thread function" do
end
end
+ describe "ruby_native_thread_p" do
+ it "returns non-zero for a ruby thread" do
+ @t.ruby_native_thread_p.should be_true
+ end
+
+ it "returns zero for a non ruby thread" do
+ @t.ruby_native_thread_p_new_thread.should be_false
+ end
+ end
+
describe "rb_thread_call_without_gvl" do
it "runs a C function with the global lock unlocked and can be woken by Thread#wakeup" do
thr = Thread.new do
@@ -155,25 +165,23 @@ describe "C-API Thread function" do
end
end
- platform_is_not :mingw do
- it "runs a C function with the global lock unlocked and unlocks IO with the generic RUBY_UBF_IO" do
- thr = Thread.new do
- @t.rb_thread_call_without_gvl_with_ubf_io
- end
+ it "runs a C function with the global lock unlocked and unlocks IO with the generic RUBY_UBF_IO" do
+ thr = Thread.new do
+ @t.rb_thread_call_without_gvl_with_ubf_io
+ end
- # Wait until it's blocking...
- Thread.pass until thr.stop?
+ # Wait until it's blocking...
+ Thread.pass until thr.stop?
- # The thread status is set to sleep by rb_thread_call_without_gvl(),
- # but the thread might not be in the blocking read(2) yet, so wait a bit.
- sleep 0.1
+ # The thread status is set to sleep by rb_thread_call_without_gvl(),
+ # but the thread might not be in the blocking read(2) yet, so wait a bit.
+ sleep 0.1
- # Wake it up, causing the unblock function to be run.
- thr.wakeup
+ # Wake it up, causing the unblock function to be run.
+ thr.wakeup
- # Make sure it stopped and we got a proper value
- thr.value.should be_true
- end
+ # Make sure it stopped and we got a proper value
+ thr.value.should be_true
end
end
end