Issue #3212 has been updated by Yusuke Endoh.

Status changed from Open to Rejected

Hi,

2010/4/28 Sylvain Joyeux <redmine / ruby-lang.org>:
> While tracking another issue with ConditionVariable, I realized that ConditionVariable#wait assumes that the waking-up side (#signal and #broadcast) will remove the thread from the list of waiters.
>
> Unfortunately, Mutex#sleep may return right away if an interrupt is set for the thread, in which case the thread will stay in the condition variable's waiting list.


I believe the behavior does not cause actual problem as long
as you use ConditionVarialbe correctly.

It is a spec that ConditionVariable may return even if it is
not signaled.  You MUST use ConditionVariable#wait in until-
loop to check your condition, like:


  mutex = Mutex.new
  cv = ConditionVariable.new

  a = Thread.start do
    mutex.synchronize do
      ...
      until (... "your condition" ...)
        cv.wait(mutex)
      end
      ...
    end
  end

  b = Thread.start do
    mutex.synchronize do
      ...
      # operation to change "your condition"
      ...
      cv.signal
    end
  end


In this usage, the waiting thread does not escape from until-
loop until the ConditionVariable is signaled.

This clumsy API came from C's condition variable (pthread_cond_
wait or so).  I guess the API may be improved to be handy, but
it is feature request.

So this ticket is false.  I close it.


If you think you are using CondtionVariable correctly, could
you elaborate the problem you are facing?
There may be another scenario of bug that I cannot think of.

-- 
Yusuke Endoh <mame / tsg.ne.jp>
----------------------------------------
http://redmine.ruby-lang.org/issues/show/3212

----------------------------------------
http://redmine.ruby-lang.org