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.



390
391
392
393
394
395
396
# File 'lib/puma/thread_pool.rb', line 390

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



398
399
400
401
402
403
404
405
406
407
408
# File 'lib/puma/thread_pool.rb', line 398

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



410
411
412
413
# File 'lib/puma/thread_pool.rb', line 410

def stop
  @running = false
  @thread.wakeup
end