On Tue, Feb 14, 2012 at 2:11 PM, Grigory Petrov <grigory.v.p / gmail.com> wro=
te:
> Hello.
>
> if i run following test code:
>
> require 'dl/import'
> module User32
> =A0extend DL::Importer
> =A0dlload 'user32'
> =A0extern 'int MessageBoxA(int, char*, char*, int)'
> end
> Thread.new { User32.MessageBoxA( 0, "Text", "Caption", 0 ) }
> loop { sleep 1; puts( "loop running" ) }
>
> I will see no "loop running" messages while message box is visible. So
> i can suggest that Ruby is not releasing GIL while calling external
> function via Ruby\dl. Why such weird architectural decision? This
> prevents me from calling blocking functions in background thread :(.

Since Ruby does not know what your external C function does (it could
manipulate Ruby objects!) it takes a conservative approach and locks.

Cheers

robert


--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/