[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: Do C Extensions Block Ruby?

hemant

9/19/2007 9:57:00 PM

On 9/20/07, Wayne E. Seguin <wayneeseguin@gmail.com> wrote:
> Does a C extension running in a ruby-thread block all ruby threads
> from running while it executes?
>

You may be aware but you can use rb_thread_schedule() for letting your
Ruby threads run.



--
Let them talk of their oriental summer climes of everlasting
conservatories; give me the privilege of making my own summer with my
own coals.

http://blog.g...

1 Answer

hemant

9/20/2007 4:24:00 PM

0

On 9/20/07, Wayne E. Seguin <wayneeseguin@gmail.com> wrote:
>
> On Sep 19, 2007, at 17:56 , hemant wrote:
> > You may be aware but you can use rb_thread_schedule() for letting your
> > Ruby threads run.
>
> hemant,
>
> Actually... no I wasn't.
>
> So if I'm in a C extension and want to let the Ruby continue
> processing can I do this:
>
> - Async Operation
> - rb_thread_schedule()
> - Wait in C ext for async operation to complete (note that this C
> extension is called from within a Ruby thread)
>
> and the C ext would not block the other Ruby threads from that point?

Yes, once you are finished with your Ruby thread and assuming no other
threads are scheduled to run, control will return back to the point in
C extension where you called rb_thread_schedule(). its basically
equivalent of Thread.pass in pure Ruby i suppose.

I hope it helps.


--
Let them talk of their oriental summer climes of everlasting
conservatories; give me the privilege of making my own summer with my
own coals.

http://g...