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.



178
179
180
181
182
# File 'lib/puma/thread_pool.rb', line 178

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

Instance Method Details

#start!Object



184
185
186
187
188
189
190
191
192
193
# File 'lib/puma/thread_pool.rb', line 184

def start!
  @running = true

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

#stopObject



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

def stop
  @running = false
  @thread.wakeup
end