> > > I'm experiencing strange behavior in a Ruby app doing
> > > multithreaded I/O, and I seem to have narrowed it down
> > > to my using a timeout { } block around a condition 
> > > variable wait.  E.g.
> > > 
> > >   timeout(1.0) { @condition_variable.wait(@mutex) }

For all the avid readers of this thread,  (ha ha... :)
just wanted to follow-up that, based on how timeout itself
is implemented, I've now switched to a timed_wait that
takes a similar approach.

Create an alarm thread, to signal the condition variable
we're waiting on, after the specified time elapses:

  def timed_wait(timeout_secs)
    begin
      alarm_th = Thread.start {
        sleep timeout_secs
        signal
      }
      wait
    ensure
      alarm_th.kill if alarm_th and alarm_th.alive?
    end
  end


This avoids having to have the Timeout::Error exception
be raised while inside #wait itself.  (See prior message
in thread for a patch to #wait to clean up its @waiters.)

Still have not been able to explain the weird behavior
seen with threads not waking up using the timeout approach
without the aforementioned patch to wait...

Now moving on to the next prob. I'm seeing which seems
to be an actual hang in the garbage collector (I'm not
loading any custom extensions or C code.)  . . . Will
start new exciting thread for that.. :)


Regards,

Bill