Class: Puma::ThreadPool::AutoTrim

Inherits:
Object
  • Object
show all
Defined in:
lib/puma/thread_pool.rb

Instance Method Summary collapse

Constructor Details

#initialize(pool, timeout) ⇒ AutoTrim

Returns a new instance of AutoTrim



159
160
161
162
163
# File 'lib/puma/thread_pool.rb', line 159

def initialize(pool, timeout)
  @pool = pool
  @timeout = timeout
  @running = false
end

Instance Method Details

#start!Object



165
166
167
168
169
170
171
172
173
174
# File 'lib/puma/thread_pool.rb', line 165

def start!
  @running = true

  @thread = Thread.new do
    while @running
      @pool.trim
      sleep @timeout
    end
  end
end

#stopObject



176
177
178
179
# File 'lib/puma/thread_pool.rb', line 176

def stop
  @running = false
  @thread.wakeup
end