From: neverland@... (Pete) Date: 2007-05-16T11:25:05+09:00 Subject: rb_yield(), semaphores and 'break' I've run into a problem that sounds superficially similar to the one that Noah Easterly posted around a month ago, but I don't think the suggested solutions work for me. 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. This all works fine, as the semaphore can be released either by a particular yield return value or by a timeout, *unless* there is a 'break' in the invoked block. The base problem is that -- although I can catch the break with an 'ensure' for instance -- the top-level 'each' is still sitting on the semaphore until that is released, but as the break has *already* popped the stack, when that function *does* terminate it just segfaults! What I seem to need to do is to prevent the break bypassing the normal return, but I can't see any way to do that. Otherwise I guess I just have to put a notice in large letters: "DO NOT USE BREAK!" (:-/) -- 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.)