Feature #20750
openAllow rb_thread_call_with_gvl to work when thread already has GVL
Description
Hello All,
I'm hoping we can make ruby_thread_has_gvl_p
a public method and no longer experimental.
I saw the following code in a gem that was not compiling with ruby 3.3:
// int ruby_thread_has_gvl_p(void); // <== line of concern
if (ruby_thread_has_gvl_p()) {
method_call(&context);
}
else {
rb_thread_call_with_gvl(method_call, &context);
}
400 unique projects on github added the line listed above to fix compilation. 1
Some of the projects detected the method first in extconf.rb
, but a majority just referenced it.
ffi
used to have the detection code but dropped it since the method was in all supported ruby versions.
It feels like this method is now part of the undocumented public interface.
My suggestion is to add the method to the real public interface in ruby/thread.h
.
PR with possible solution: https://github.com/ruby/ruby/pull/11619
Also included a patch if that is easier
Thank you for your consideration,
Keenan
Timeline:
- Dec 30 2008 -
rb_thread_call_with_gvl
introduced via 9c04a06 2 - Jan 12 2009 -
ruby_thread_has_gvl_p
introduced via 6f09fc2 4 - Jul 18 2012 -
rb_thread_call_with_gvl
made public via e9a91d2 3
Current references to code: rb_thread_call_with_gvl
5 ruby_thread_has_gvl_p
6:
Files