Class: Puma::ThreadPool::Automaton

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

Instance Method Summary collapse

Constructor Details

#initialize(pool, timeout, thread_name, message) ⇒ Automaton

Returns a new instance of Automaton.


247
248
249
250
251
252
253
# File 'lib/puma/thread_pool.rb', line 247

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

Instance Method Details

#start!Object


255
256
257
258
259
260
261
262
263
264
265
# File 'lib/puma/thread_pool.rb', line 255

def start!
  @running = true

  @thread = Thread.new do
    Puma.set_thread_name @thread_name
    while @running
      @pool.public_send(@message)
      sleep @timeout
    end
  end
end

#stopObject


267
268
269
270
# File 'lib/puma/thread_pool.rb', line 267

def stop
  @running = false
  @thread.wakeup
end