aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
authorDevin Christensen <quixoten@gmail.com>2017-04-13 13:56:42 -0600
committerDevin Christensen <quixoten@gmail.com>2017-04-13 13:56:42 -0600
commit6116d7bc052839646f448b8403a7287f52b97ed7 (patch)
treeae08d005831f354e404664af038ded259fd0f824 /activerecord/lib/active_record/connection_adapters
parent3360742396a00c9e2ff9838373788bed432d5ea7 (diff)
downloadrails-6116d7bc052839646f448b8403a7287f52b97ed7.tar.gz
rails-6116d7bc052839646f448b8403a7287f52b97ed7.tar.bz2
rails-6116d7bc052839646f448b8403a7287f52b97ed7.zip
Improve documentation and add test
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb11
1 files changed, 4 insertions, 7 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 ea76ff983e..3dc265622d 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -80,11 +80,8 @@ module ActiveRecord
# * private methods that require being called in a +synchronize+ blocks
# are now explicitly documented
class ConnectionPool
- # Threadsafe, fair, LIFO 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, FIFO queue. Meant to be used by ConnectionPool
+ # with which it shares a Monitor.
class Queue
def initialize(lock = Monitor.new)
@lock = lock
@@ -111,7 +108,7 @@ module ActiveRecord
# Add +element+ to the queue. Never blocks.
def add(element)
synchronize do
- @queue.unshift element
+ @queue.push element
@cond.signal
end
end
@@ -173,7 +170,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