Rb_thread_blocking_region documentation?

Hi,

I am working on making our Ruby-C extension support Ruby-1.9’s
rb_thread_blocking_region feature to have the lock released while
doing a long time consuming operation. Could anybody point me to some
documentation or some links where I will be able to get more details
on the parameters this method is expecting and also the type signature
of parameters the unblock function is expecting.

I went through this link of mail thread where Sasada has replied
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/10252 This
mail thread is old and also in this the rb_thread_blocking_region
method’s signature expects only 3 parameters, however when this is
implemented and compiled it throws any arguments mismatch error.
Further googling I found that it expects 4 parameters. Also this link
says the type of parameter the unblocking fucntion expects is
rb_thread_t * , so who will be passing this thread reference. Could
somebody help me out in knowing what is the type signature of the
parameters that the function is expecting.

Help highly appreciated!

Thanks

Praveen

rb_thread_blocking_region
Help highly appreciated!

The only thing I’ve found helpful was to examine the code where
EventMachine used it and try and copy that :slight_smile:

mysqlplus uses it.

http://betterlogic.com/roger/?p=456
explains it slightly.
I dunno where the “real” docu for it is, though.
-=r

Hi,

On Thu, Apr 2, 2009 at 11:34 PM, Praveen [email protected]
wrote:

… Also this link
says the type of parameter the unblocking fucntion expects is
rb_thread_t * , so who will be passing this thread reference.

No. It depends on the type of the unblocking function.
The forth parameter of rb_thread_blocking_region is passed to the
unblocking function
as it is. Exceptionally when RUBY_UBF_IO or RUBY_UBF_PROCESS is passed
to
the third parameter, the fourth is ignored.

Indeed ubf_select in thread_pthread.c and thread_win32.c expects
rb_thread_t*.
But you have no need to pass it. It is set by rb_thread_blocking_region
when
RUBY_UBF_IO or RUBY_UBF_PROCESS is passed.

As far as I looked in the code, it makes a segmentation fault when the
blocking
thread is woken up by Thread#wakeup.
The third parameter of rb_thread_blocking_region_variable_params in the
mysql.c
is passed to rb_thread_blocking_region’s third parameter. It should be
an unblocking
function, not an integer.

The third parameter appears to be “interrupter” which is a void * is
that a bug?
Thanks!
-=r

Roger P. wrote:

As far as I looked in the code, it makes a segmentation fault when the
blocking
thread is woken up by Thread#wakeup.
The third parameter of rb_thread_blocking_region_variable_params in the
mysql.c
is passed to rb_thread_blocking_region’s third parameter. It should be
an unblocking
function, not an integer.

The third parameter appears to be “interrupter” which is a void * is
that a bug?
Thanks!
-=r

Oh I see it now–when I was using the function I was passing “8” instead
of RUBY_UBF_IO. I’ll update the code and post an announcement here when
it works :slight_smile:
-=r

Hi,

On Sat, Apr 4, 2009 at 2:40 PM, Roger P. [email protected]
wrote:

explains it slightly.
I dunno where the “real” docu for it is, though.

quote from the blog.

http://github.com/oldmoe/mysqlplus/tree/19_non_gvl_connect/ext/mysql.c

VALUE answer = rb_thread_blocking_region_variable_params(total_params_right_here - 1, &func_pointer, how_many_params_the_function_takes, param1,param2,param3);

As far as I looked in the code, it makes a segmentation fault when the
blocking
thread is woken up by Thread#wakeup.
The third parameter of rb_thread_blocking_region_variable_params in the
mysql.c
is passed to rb_thread_blocking_region’s third parameter. It should be
an unblocking
function, not an integer.