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.



141
142
143
144
145
# File 'lib/puma/thread_pool.rb', line 141

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

Instance Method Details

#start!Object



147
148
149
150
151
152
153
154
155
156
# File 'lib/puma/thread_pool.rb', line 147

def start!
  @running = true

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

#stopObject



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

def stop
  @running = false
  @thread.wakeup
end