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.rb34
1 files changed, 20 insertions, 14 deletions
diff --git a/spec/ruby/optional/capi/thread_spec.rb b/spec/ruby/optional/capi/thread_spec.rb
index 5cb46bbb7c..117726f0e2 100644
--- a/spec/ruby/optional/capi/thread_spec.rb
+++ b/spec/ruby/optional/capi/thread_spec.rb
@@ -165,24 +165,30 @@ 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
+ end
- # Make sure it stopped and we got a proper value
- thr.value.should be_true
+ ruby_version_is "4.0" do
+ describe "ruby_thread_has_gvl_p" do
+ it "returns true if the current thread has the GVL" do
+ @t.ruby_thread_has_gvl_p.should be_true
end
end
end