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:
commit
0ded7fbbdd
4 changed files with 18 additions and 8 deletions
|
@ -178,11 +178,11 @@ module Puma
|
||||||
o.on '-t', '--threads INT', "min:max threads to use (default 0:16)" do |arg|
|
o.on '-t', '--threads INT', "min:max threads to use (default 0:16)" do |arg|
|
||||||
min, max = arg.split(":")
|
min, max = arg.split(":")
|
||||||
if max
|
if max
|
||||||
@options[:min_threads] = min.to_i
|
@options[:min_threads] = min
|
||||||
@options[:max_threads] = max.to_i
|
@options[:max_threads] = max
|
||||||
else
|
else
|
||||||
@options[:min_threads] = 0
|
@options[:min_threads] = 0
|
||||||
@options[:max_threads] = arg.to_i
|
@options[:max_threads] = arg
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@ module Puma
|
||||||
@spawned = 0
|
@spawned = 0
|
||||||
@waiting = 0
|
@waiting = 0
|
||||||
|
|
||||||
@min = min
|
@min = Integer(min)
|
||||||
@max = max
|
@max = Integer(max)
|
||||||
@block = block
|
@block = block
|
||||||
@extra = extra
|
@extra = extra
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ module Puma
|
||||||
@auto_trim = nil
|
@auto_trim = nil
|
||||||
|
|
||||||
@mutex.synchronize do
|
@mutex.synchronize do
|
||||||
min.times { spawn_thread }
|
@min.times { spawn_thread }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@ module Rack
|
||||||
puts "* Listening on tcp://#{options[:Host]}:#{options[:Port]}"
|
puts "* Listening on tcp://#{options[:Host]}:#{options[:Port]}"
|
||||||
|
|
||||||
server.add_tcp_listener options[:Host], options[:Port]
|
server.add_tcp_listener options[:Host], options[:Port]
|
||||||
server.min_threads = Integer(min)
|
server.min_threads = min
|
||||||
server.max_threads = Integer(max)
|
server.max_threads = max
|
||||||
yield server if block_given?
|
yield server if block_given?
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -32,6 +32,16 @@ class TestThreadPool < Test::Unit::TestCase
|
||||||
assert_equal 1, pool.spawned
|
assert_equal 1, pool.spawned
|
||||||
end
|
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
|
def test_append_queues_on_max
|
||||||
finish = false
|
finish = false
|
||||||
pool = new_pool(0, 1) { Thread.pass until finish }
|
pool = new_pool(0, 1) { Thread.pass until finish }
|
||||||
|
|
Loading…
Reference in a new issue