From: Michael Witrant Date: 2002-03-01T21:02:01+09:00 Subject: Re: RCR?: parallel to until: as_soon_as On Wed, 27 Feb 2002 18:16:27 +0900 Tobias Reif wrote: > Perhaps some shorter(and perhaps slower) construct might be a nice > alternative. I wrote for myself a Signal class to handle events. I think ruby 1.7 includes a Signal class I don't know anything about, so my class name might change. Basically, you define a new signal like this: button_pressed = Signal.new In a thread, you "emit" the signal using button_pressed.emit("foo", 1, 2) And wait for the signal in another thread like this: name, a, b = button_pressed.wait or like this: button_pressed.wait_each { |name, a, b| ... this block is executed each time the signal is emited ... } The wait_each call can be placed in a thread created only to handle this signal. It uses Queues to manage the waiting threads. The code is quite small (about 60 lines). Would it be usefull to anyone if I released it? Mike.