From: neverland@... (Pete) Date: 2007-05-16T12:05:04+09:00 Subject: Re: rb_yield(), semaphores and 'break' In article <200705160246.l4G2kB3u024158@sharui.nakada.kanuma.tochigi.jp>, Nobuyoshi Nakada wrote: >Hi, > >At Wed, 16 May 2007 11:25:05 +0900, >Pete wrote in [ruby-talk:251756]: >> Here's the sitch... I'm working on an extension to handle real-time >> MIDI, and my concept is to have an 'each' method for the MidiIn class >> that will just feed events to a block as they arrive. This is implemented >> by the 'each' (C++) function making the block available to a callback >> function, which is itself called by the Midi handler for each arriving >> event, and does a rb_yield(). The original function is meanwhile just >> sitting on a semaphore, and will return when that is released. > >What semaphore? ruby's or C++'s? Sorry -- too brief... This is an OS (BeOS! (:-/)) semaphore (C++ level). > >Have you tried rb_ensure()? Yes. That's what I was referring to. I can 'capture' the break with a function pointed to by an rb_ensure call, but the problem is that the 'body' part of that call is *still* sitting on the semaphore, so that if I release it from the ensure section, it is too late -- the stack is already popped. It tries to return at that point, and Boom! At least that's what seems to be happening. Unless someone can correct me... -- Pete -- -- ============================================================================ The address in the header is a Spam Bucket -- don't bother replying to it... (If you do need to email, replace the account name with my true name.)