123456789_123456789_123456789_123456789_123456789_

Module: ActiveRecord::ConnectionAdapters::ConnectionPool::BiasableQueue

Do not use. This module is for internal use only.
Relationships & Source Files
Namespace Children
Classes:
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: activerecord/lib/active_record/connection_adapters/abstract/connection_pool/queue.rb

Overview

Adds the ability to turn a basic fair FIFO queue into one biased to some thread.

Instance Method Summary

Instance Method Details

#with_a_bias_for(thread)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool/queue.rb', line 177

def with_a_bias_for(thread)
  previous_cond = nil
  new_cond      = nil
  synchronize do
    previous_cond = @cond
    @cond = new_cond = BiasedConditionVariable.new(@lock, @cond, thread)
  end
  yield
ensure
  synchronize do
    @cond = previous_cond if previous_cond
    new_cond.broadcast_on_biased if new_cond # wake up any remaining sleepers
  end
end