Module: ActiveRecord::ConnectionAdapters::ConnectionPool::BiasableQueue
- Included in:
- ConnectionLeasingQueue
- Defined in:
- lib/active_record/connection_adapters/abstract/connection_pool.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
251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 251 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 |