Forum: Ruby rb_thread_blocking_region documentation?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Praveen (Guest)
on 2009-04-02 18:35
(Received via mailing list)
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/... 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
Roger P. (Guest)
on 2009-04-04 09:41
> 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 :)

mysqlplus uses it.

http://betterlogic.com/roger/?p=456
explains it slightly.
I dunno where the "real" docu for it is, though.
-=r
Takehiro K. (Guest)
on 2009-04-04 12:49
(Received via mailing list)
Hi,

On Thu, Apr 2, 2009 at 11:34 PM, Praveen <removed_email_address@domain.invalid>
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.
Takehiro K. (Guest)
on 2009-04-04 13:35
(Received via mailing list)
Hi,

On Sat, Apr 4, 2009 at 2:40 PM, Roger P. <removed_email_address@domain.invalid>
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...
>
> 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.
Roger P. (Guest)
on 2009-04-19 00:30
> 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. (Guest)
on 2009-04-19 01:40
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 :)
-=r
This topic is locked and can not be replied to.