Glib2: rb_thread_blocking_region removed from Ruby

Dear Kou and other readers:

today I compiled ruby-gnome2 from git using ruby from svn, and I
encountered a snag.

It appears that function rb_thread_blocking_region, that was
deprecated, has been eventually removed for good. This function is
only used once in rbglib_maincontext.c.

Substituting it is easy, from what I read: include <ruby/thread.h> and
then call rb_thread_call_without_gvl instead of
rb_thread_blocking_region, with exactly the same parameters.

But there is a problem. Usage of rb_thread_blocking_region is governed
by a macro (HAVE_RB_THREAD_BLOCKING_REGION) that’s defined during
configuration, and if the function is not found, some code which is I
believe older than the insertion of that function is compiled in - see
lines 24-32 of rbglib_maincontext.c. I believe this is old stuff
because there is no way to include version.h like it is done there.

I was able to complete the compilation by:

  1. adding a

#define HAVE_RB_THREAD_BLOCKING_REGION

before #ifdef HAVE_RB_THREAD_BLOCKING_REGION in rgbprivate.h,

  1. adding a

#include <ruby/thread.h>

after including rgbprivate.h, in rbglib_maincontext.c, and

  1. substituting

    rb_thread_blocking_region(rg_poll_in_blocking, &info, RUBY_UBF_IO,
    NULL);

with

rb_thread_call_without_gvl(rg_poll_in_blocking, &info, RUBY_UBF_IO, 

NULL);

around line 95 in rbglib_maincontext.c.

Of course it’s an ugly hack. I am sure you will concoct the correct
magic, though.

Carlo

  •     Se la Strada e la sua Virtu' non fossero state messe da 
    

parte,

  • K * Carlo E. Prelz - [email protected] che bisogno ci
    sarebbe
    •           di parlare tanto di amore e di rettitudine? 
      

(Chuang-Tzu)

Hi,

In [email protected]
“[ruby-gnome2-devel-en] glib2: rb_thread_blocking_region removed from
Ruby” on Mon, 10 Mar 2014 16:57:31 +0100,
“Carlo E. Prelz” [email protected] wrote:

today I compiled ruby-gnome2 from git using ruby from svn, and I
encountered a snag.

It is strange. I committed changes that support Ruby trunk a
few days ago.

Oh… I forgot to push the commit…
It didn’t included in Ruby-GNOME2 2.2.0…

I’ve pushed it now:
https://github.com/ruby-gnome2/ruby-gnome2/commit/c92a046cfe266cedbd59a40b31cfc9ea6e8ab300

It was my mistake. Sorry…

Thanks,

kou

Subject: Re: [ruby-gnome2-devel-en] glib2: rb_thread_blocking_region
removed from Ruby
Date: mar 11 mar 14 10:09:44 +0900

Quoting Kouhei S. ([email protected]):

It is strange. I committed changes that support Ruby trunk a
few days ago.

Oh… I forgot to push the commit…
It didn’t included in Ruby-GNOME2 2.2.0…

I’ve pushed it now:

It was my mistake. Sorry…

No problem. And thanks as usual for the huge effort you are putting on
all of this.

Carlo

  •     Se la Strada e la sua Virtu' non fossero state messe da 
    

parte,

  • K * Carlo E. Prelz - [email protected] che bisogno ci
    sarebbe
    •           di parlare tanto di amore e di rettitudine? 
      

(Chuang-Tzu)

Hi,

In [email protected]
“Re: [ruby-gnome2-devel-en] glib2: rb_thread_blocking_region removed
from Ruby” on Tue, 11 Mar 2014 14:14:13 +0100,
“Carlo E. Prelz” [email protected] wrote:

No problem. And thanks as usual for the huge effort you are putting on
all of this.

Thanks. And thanks for your report. :slight_smile:


kou