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.



296
297
298
299
300
301
302
# File 'lib/puma/thread_pool.rb', line 296

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



304
305
306
307
308
309
310
311
312
313
314
# File 'lib/puma/thread_pool.rb', line 304

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



316
317
318
319
# File 'lib/puma/thread_pool.rb', line 316

def stop
  @running = false
  @thread.wakeup
end