123456789_123456789_123456789_123456789_123456789_

Class: ActiveRecord::ConnectionAdapters::ConnectionPool::ConnectionLeasingQueue

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Queue
Instance Chain:
Inherits: ActiveRecord::ConnectionAdapters::ConnectionPool::Queue
Defined in: activerecord/lib/active_record/connection_adapters/abstract/connection_pool/queue.rb

Overview

Connections must be leased while holding the main pool mutex. This is an internal subclass that also .leases returned connections while still in queue’s critical section (queue synchronizes with the same @lock as the main pool) so that a returned connection is already leased and there is no need to re-enter synchronized block.

Class Method Summary

Queue - Inherited

Instance Attribute Summary

Queue - Inherited

#any_waiting?

Test if any threads are currently waiting on the queue.

#any?

Test if the queue currently contains any elements.

#can_remove_no_wait?

A thread can remove an element from the queue without waiting if and only if the number of currently available connections is strictly greater than the number of waiting threads.

Instance Method Summary

BiasableQueue - Included

Queue - Inherited

#add

Add element to the queue.

#clear

Remove all elements from the queue.

#delete

If element is in the queue, remove and return it, or nil.

#num_waiting

Returns the number of threads currently waiting on this queue.

#poll

Remove the head of the queue.

#internal_poll,
#no_wait_poll

Remove and return the head of the queue if the number of available elements is strictly greater than the number of threads currently waiting.

#remove

Removes and returns the head of the queue if possible, or nil.

#synchronize,
#wait_poll

Waits on the queue up to timeout seconds, then removes and returns the head of the queue.

Constructor Details

This class inherits a constructor from ActiveRecord::ConnectionAdapters::ConnectionPool::Queue

Instance Method Details

#internal_poll(timeout) (private)

[ GitHub ]

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

def internal_poll(timeout)
  conn = super
  conn.lease if conn
  conn
end