1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

use a latch to avoid busy loops

This commit is contained in:
Aaron Patterson 2014-03-17 17:29:33 -07:00
parent 8f218266bb
commit 4db4f90917

View file

@ -1,4 +1,5 @@
require "cases/helper"
require 'active_support/concurrency/latch'
module ActiveRecord
module ConnectionAdapters
@ -133,15 +134,15 @@ module ActiveRecord
end
def test_reap_inactive
ready = false
ready = ActiveSupport::Concurrency::Latch.new
@pool.checkout
child = Thread.new do
@pool.checkout
@pool.checkout
ready = true
ready.release
Thread.stop
end
Thread.pass until ready
ready.await
assert_equal 3, active_connections(@pool).size