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
260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 260 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 |