Skip to content

Commit

Permalink
clean up, and sleep just long enough to get work done in tests should…
Browse files Browse the repository at this point in the history
… fix rbx
  • Loading branch information
JoshMcKin committed Feb 7, 2014
1 parent 29ec50d commit 596f259
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
2 changes: 0 additions & 2 deletions lib/hot_tub/pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ def initialize(opts={},&client_block)
@pool.taint
@register = [] # stores all connections at all times
@register.taint
@waiting = [] # waiting threads
@waiting.taint
@orphans = [] # orphan connections to be reaped
@orphans.taint

Expand Down
26 changes: 5 additions & 21 deletions spec/pool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
pool.run{|connection| connection.get }
end
end
sleep(1)
sleep(0.01)
threads.each do |t|
t.join
end
Expand All @@ -188,7 +188,7 @@
pool.run{|connection| connection.get }
end
end
sleep(0.2)
sleep(0.01)
threads.each do |t|
t.join
end
Expand All @@ -206,7 +206,7 @@
pool.instance_variable_set(:@current_size, 2)
pool.send(:_reap_pool?).should be_true
pool.instance_variable_get(:@reaper).wakeup # run the reaper thread
sleep(0.001) # let results
sleep(0.01) # let results
pool.current_size.should eql(1)
pool.instance_variable_get(:@pool).length.should eql(1)
end
Expand Down Expand Up @@ -276,7 +276,7 @@
}
end
end
sleep(0.001)
sleep(0.01)
threads.each do |t|
t.join
end
Expand All @@ -290,7 +290,7 @@
@pool.run{|connection| Thread.current[:status] = connection.head(uri.path).code }
end
end
sleep(0.001)
sleep(0.01)
threads.each do |t|
t.join
end
Expand All @@ -301,20 +301,4 @@
end
end
end
# describe "benchmark" do
# @pool = HotTub::Pool.new {Object.new}
# now = Time.now
# threads = []
# 30000.times.each do
# threads << Thread.new do
# @pool.run{|conn|
# }
# end
# end
# sleep(0.001)
# threads.each do |t|
# t.join
# end
# puts Time.now - now
# end
end

0 comments on commit 596f259

Please sign in to comment.