aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2017-11-17 23:48:16 +1030
committerGitHub <noreply@github.com>2017-11-17 23:48:16 +1030
commiteed3d3fff5ca6be00b2fe0fe020bd025ddbabbd5 (patch)
tree35b8ba1dcdc892570575ebe8efbdbc7e6e99b47d /activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
parentcd3c0fa3d04b634e272b4f5b232fdd433b3238f4 (diff)
parent47d678d9b2ab6d3e888691e8327e657ff0b5dcb0 (diff)
downloadrails-eed3d3fff5ca6be00b2fe0fe020bd025ddbabbd5.tar.gz
rails-eed3d3fff5ca6be00b2fe0fe020bd025ddbabbd5.tar.bz2
rails-eed3d3fff5ca6be00b2fe0fe020bd025ddbabbd5.zip
Merge pull request #28742 from quixoten/stack_conn_pool
Switch to LIFO for the connection pool
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb9
1 files changed, 3 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
index 0759f4d2b3..6c06f67239 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -82,11 +82,8 @@ module ActiveRecord
# * private methods that require being called in a +synchronize+ blocks
# are now explicitly documented
class ConnectionPool
- # Threadsafe, fair, FIFO queue. Meant to be used by ConnectionPool
- # with which it shares a Monitor. But could be a generic Queue.
- #
- # The Queue in stdlib's 'thread' could replace this class except
- # stdlib's doesn't support waiting with a timeout.
+ # Threadsafe, fair, LIFO queue. Meant to be used by ConnectionPool
+ # with which it shares a Monitor.
class Queue
def initialize(lock = Monitor.new)
@lock = lock
@@ -175,7 +172,7 @@ module ActiveRecord
# Removes and returns the head of the queue if possible, or +nil+.
def remove
- @queue.shift
+ @queue.pop
end
# Remove and return the head the queue if the number of