提交 4db4f909 编写于 作者: A Aaron Patterson

use a latch to avoid busy loops

上级 8f218266
require "cases/helper" require "cases/helper"
require 'active_support/concurrency/latch'
module ActiveRecord module ActiveRecord
module ConnectionAdapters module ConnectionAdapters
...@@ -133,15 +134,15 @@ def test_reap_and_active ...@@ -133,15 +134,15 @@ def test_reap_and_active
end end
def test_reap_inactive def test_reap_inactive
ready = false ready = ActiveSupport::Concurrency::Latch.new
@pool.checkout @pool.checkout
child = Thread.new do child = Thread.new do
@pool.checkout @pool.checkout
@pool.checkout @pool.checkout
ready = true ready.release
Thread.stop Thread.stop
end end
Thread.pass until ready ready.await
assert_equal 3, active_connections(@pool).size assert_equal 3, active_connections(@pool).size
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册