From: "Iñaki Baz Castillo" Date: 2012-04-17T19:15:45+09:00 Subject: GVL lock and unlock Hi, I'm coding a Ruby wrapper for libuv (the event-driven library used in node.js). At some point I cann "uv_run()" which is blocking and start the reactor loop, so I need to unlock the GVL: VALUE MyLib_loop_start(VALUE self) { # Allow other Ruby threads to run. # TODO: unlock_GVL function ??? uv_run(uv_default_loop()); # At some point (when there is no more events to watch) # uv_run terminates, so I need to take the GVL again. # TODO: lock_GVL function ??? return self; } So how should I fill the above GVL functions? I use Ruby 1.9.3. I expected that GVL_UNLOCK_BEGIN/END [*] could work but they are not defined in any .h file but in thread.c. Any tip please? Thanks a lot. BTW: During the libuv event loop, Ruby callbacks will be called. Should I take the GVL before invoking them? [*] http://rxr.whitequark.org/mri/source/thread.c?v=1.9.3#106 -- Iñaki Baz Castillo