1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Merge pull request #327 from lmarburger/convert-thread-pool-sizes

Convert thread pool sizes to integers
This commit is contained in:
Evan Phoenix 2013-07-18 16:54:24 -07:00
commit 0ded7fbbdd
4 changed files with 18 additions and 8 deletions

View file

@ -178,11 +178,11 @@ module Puma
o.on '-t', '--threads INT', "min:max threads to use (default 0:16)" do |arg|
min, max = arg.split(":")
if max
@options[:min_threads] = min.to_i
@options[:max_threads] = max.to_i
@options[:min_threads] = min
@options[:max_threads] = max
else
@options[:min_threads] = 0
@options[:max_threads] = arg.to_i
@options[:max_threads] = arg
end
end

View file

@ -20,8 +20,8 @@ module Puma
@spawned = 0
@waiting = 0
@min = min
@max = max
@min = Integer(min)
@max = Integer(max)
@block = block
@extra = extra
@ -34,7 +34,7 @@ module Puma
@auto_trim = nil
@mutex.synchronize do
min.times { spawn_thread }
@min.times { spawn_thread }
end
end

View file

@ -31,8 +31,8 @@ module Rack
puts "* Listening on tcp://#{options[:Host]}:#{options[:Port]}"
server.add_tcp_listener options[:Host], options[:Port]
server.min_threads = Integer(min)
server.max_threads = Integer(max)
server.min_threads = min
server.max_threads = max
yield server if block_given?
begin

View file

@ -32,6 +32,16 @@ class TestThreadPool < Test::Unit::TestCase
assert_equal 1, pool.spawned
end
def test_converts_pool_sizes
pool = new_pool('0', '1')
assert_equal 0, pool.spawned
pool << 1
assert_equal 1, pool.spawned
end
def test_append_queues_on_max
finish = false
pool = new_pool(0, 1) { Thread.pass until finish }