class Puma::ThreadPool
A simple thread pool management object.
Attributes
clean_thread_locals[RW]
spawned[R]
trim_requested[R]
Public Class Methods
clean_thread_locals()
click to toggle source
# File lib/puma/thread_pool.rb, line 51 def self.clean_thread_locals Thread.current.keys.each do |key| Thread.current[key] = nil unless key == :__recursive_key__ end end
new(min, max, *extra, &block)
click to toggle source
Maintain a minimum of min
and maximum of max
threads in the pool.
The block passed is the work that will be performed in each thread.
# File lib/puma/thread_pool.rb, line 17 def initialize(min, max, *extra, &block) @not_empty = ConditionVariable.new @not_full = ConditionVariable.new @mutex = Mutex.new @todo = [] @spawned = 0 @waiting = 0 @min = Integer(min) @max = Integer(max) @block = block @extra = extra @shutdown = false @trim_requested = 0 @workers = [] @auto_trim = nil @reaper = nil @mutex.synchronize do @min.times { spawn_thread } end @clean_thread_locals = false end
Public Instance Methods
backlog()
click to toggle source
How many objects have yet to be processed by the pool?
# File lib/puma/thread_pool.rb, line 59 def backlog @mutex.synchronize { @todo.size } end