Bug #6174

Fix collision of ConditionVariable#wait timeout and #signal (+ other cosmetic changes)

Added by funny_falcon (Yura Sokolov) almost 9 years ago. Updated over 8 years ago.

Target version:
ruby -v:
ruby 2.0.0dev (2012-03-17 trunk 35075) [i686-linux]


  1. Currently, when Thread wakes on timeout, it could not remove itself from ConditionVariable waiters until it acquires lock. So that, when ConditionVariable#signal is called, it will try to wakeup such thread, instead of some one else.

Simple way to avoid it, is to allow Mutex#sleep to recieve a block, which will be called right after Thread will awake, but before Mutex will be tried to lock

  1. Since MatzRuby use GVL for thread isolation, and native method could not be interrupted (unless it will), we could remove couple of calles to Mutex#synchronize

  2. Usage of hash with compare_by_identity allows remove call to Array#include? in a Queue. Also it allows to remove other call Mutex#synchronize from ConditionVariable#wait in case when we rely on GVL.

  3. And cosmetic changes to SizedQueue

Pull request at once:

Related issues

Related to Ruby master - Feature #6762: Control interrupt timingClosedko1 (Koichi Sasada)07/21/2012Actions

Also available in: Atom PDF