class ActiveRecord::ConnectionAdapters::ConnectionPool::BiasableQueue::BiasedConditionVariable
:nodoc:
:nodoc:
biased to some thread.
Adds the ability to turn a basic fair FIFO queue into one
def broadcast
def broadcast broadcast_on_biased @other_cond.broadcast end
def broadcast_on_biased
def broadcast_on_biased @num_waiting_on_real_cond = 0 @real_cond.broadcast end
def initialize(lock, other_cond, preferred_thread)
semantics of condition variables guarantee that +broadcast+, +broadcast_on_biased+,
:nodoc:
:nodoc:
biased to some thread.
Adds the ability to turn a basic fair FIFO queue into one
def initialize(lock, other_cond, preferred_thread) @real_cond = lock.new_cond @other_cond = other_cond @preferred_thread = preferred_thread @num_waiting_on_real_cond = 0 end
def signal
def signal if @num_waiting_on_real_cond > 0 @num_waiting_on_real_cond -= 1 @real_cond else @other_cond end.signal end
def wait(timeout)
def wait(timeout) if Thread.current == @preferred_thread @num_waiting_on_real_cond += 1 @real_cond else @other_cond end.wait(timeout) end