minor: cleanup thread_to_socket pruning code and test
This commit is contained in:
parent
c65b4aadb0
commit
aab3cf7b74
|
@ -227,15 +227,10 @@ module Mongo
|
|||
end
|
||||
|
||||
def prune_thread_socket_hash
|
||||
map = {}
|
||||
Thread.list.each do |t|
|
||||
map[t] = 1
|
||||
end
|
||||
current_threads = Set[*Thread.list]
|
||||
|
||||
@threads_to_sockets.keys.each do |key|
|
||||
if !map[key]
|
||||
@threads_to_sockets.delete(key)
|
||||
end
|
||||
@threads_to_sockets.delete_if do |thread, socket|
|
||||
!current_threads.include?(thread)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -12,12 +12,10 @@ class PoolTest < Test::Unit::TestCase
|
|||
@pool = Pool.new(@connection, TEST_HOST, TEST_PORT, :size => 5)
|
||||
|
||||
@threads = []
|
||||
@sockets = []
|
||||
|
||||
10.times do
|
||||
@threads << Thread.new do
|
||||
original_socket = @pool.checkout
|
||||
@sockets << original_socket
|
||||
@pool.checkin(original_socket)
|
||||
5000.times do
|
||||
socket = @pool.checkout
|
||||
|
|
Loading…
Reference in New Issue