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:
parent
8f218266bb
commit
4db4f90917
1 changed files with 4 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue