minor: cleanup thread_to_socket pruning code and test

This commit is contained in:
Tyler Brock 2012-04-03 14:15:17 -04:00
parent c65b4aadb0
commit aab3cf7b74
2 changed files with 3 additions and 10 deletions

View File

@ -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

View File

@ -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