[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

rb_thread_blocking_region documentation?

Praveen

4/2/2009 2:35:00 PM

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-... 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
5 Answers

Roger Pack

4/4/2009 5:41:00 AM

0


> 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/ro...
explains it slightly.
I dunno where the "real" docu for it is, though.
-=r

--
Posted via http://www.ruby-....

KUBO Takehiro

4/4/2009 8:48:00 AM

0

Hi,

On Thu, Apr 2, 2009 at 11:34 PM, Praveen <praveendevarao@gmail.com> 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.

KUBO Takehiro

4/4/2009 9:33:00 AM

0

Hi,

On Sat, Apr 4, 2009 at 2:40 PM, Roger Pack <rogerpack2005@gmail.com> wrote:
>
>> 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/ro...
> 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/e...
>
> 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 Pack

4/18/2009 8:31:00 PM

0


> 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
--
Posted via http://www.ruby-....

Roger Pack

4/18/2009 9:41:00 PM

0

Roger Pack 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
--
Posted via http://www.ruby-....