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.



195
196
197
198
199
# File 'lib/puma/thread_pool.rb', line 195

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

Instance Method Details

#start!Object



201
202
203
204
205
206
207
208
209
210
# File 'lib/puma/thread_pool.rb', line 201

def start!
  @running = true

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

#stopObject



212
213
214
215
# File 'lib/puma/thread_pool.rb', line 212

def stop
  @running = false
  @thread.wakeup
end