Module: ActiveRecord::ConnectionAdapters::ConnectionPool::BiasableQueue
- Included in:
- ConnectionLeasingQueue
- Defined in:
- 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.
Defined Under Namespace
Classes: BiasedConditionVariable
Instance Method Summary collapse
Instance Method Details
#with_a_bias_for(thread) ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File '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 |