From: Tony Arcieri Date: 2012-04-28T12:35:02+09:00 Subject: Re: GVL lock and unlock --0015175ce024e2415304beb4e78f Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Err whoops, sorry, didn't see this while I was at RailsConf. But yes, you've got it! ;) Can't wait to see what you do with libuv. I will probably need to do something similar with nio4r, but I only want to expose a subset of what libuv provides. On Tue, Apr 24, 2012 at 4:32 AM, I=F1aki Baz Castillo wrote= : > 2012/4/24 I=F1aki Baz Castillo : > > Ok, so in summary: > > > > - I must release the GVL *before* running the uv loop (which is a > > blocking function that just returns when there are no listeners in the > > loop). If not, other Ruby threads cannot work (already verified). > > So I must use rb_thread_call_without_gvl(). > > > > > - And I must take again the GVL when a uv callback occurs (i.e. a > > timer) and I must execute some associated Ruby code (i.e. a > > block.call), and then I must release again the GVL after such a Ruby > > code terminates so uv takes again the control and the GVL is released > > for other Ruby threads to work. > > So I must use rb_thread_call_with_gvl(). > > > > -- > I=F1aki Baz Castillo > > --=20 Tony Arcieri --0015175ce024e2415304beb4e78f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Err whoops, sorry, didn't see this while I w= as at RailsConf.

But yes, you've got it! ;)
<= br>
Can't wait to see what you do with libuv. I = will probably need to do something similar with nio4r, but I only want to e= xpose a subset of what libuv provides.

On= Tue, Apr 24, 2012 at 4:32 AM, I=F1aki Baz Castillo <<= a href=3D"mailto:ibc@aliax.net" target=3D"_blank">ibc@aliax.net> wrote:
2012/4/24 I=F1aki Baz Castillo <ibc@aliax.net>:
> Ok, so in summary:
>
> - I must release the GVL *before* running the uv loop (which is a
> blocking function that just returns when there are no listeners in the=
> loop). If not, other Ruby threads cannot work (already verified).

So I must use rb_thread_call_without_gvl().



> - And I must take again the GVL when a uv callback occurs (i.e. a
> timer) and I must execute some associated Ruby code (i.e. a
> block.call), and then I must release again the GVL after such a Ruby > code terminates so uv takes again the control and the GVL is released<= br> > for other Ruby threads to work.

So I must use rb_thread_call_with_gvl().



--
I=F1aki Baz Castillo
<ibc@aliax.net>



--
= Tony Arcieri

--0015175ce024e2415304beb4e78f--