Class: Sequel::Database::AsyncThreadPool::JobProcessor
- Defined in:
- lib/sequel/extensions/async_thread_pool.rb
Overview
JobProcessor is a wrapper around a single thread, that will process a queue of jobs until it is shut down.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(queue) ⇒ JobProcessor
constructor
A new instance of JobProcessor.
-
#join ⇒ Object
Join the thread, should only be called by the related finalizer.
Constructor Details
#initialize(queue) ⇒ JobProcessor
Returns a new instance of JobProcessor.
215 216 217 218 219 220 221 |
# File 'lib/sequel/extensions/async_thread_pool.rb', line 215 def initialize(queue) @thread = ::Thread.new do while proxy = queue.pop proxy.__send__(:__run) end end end |
Class Method Details
.create_finalizer(queue, pool) ⇒ Object
:nodoc:
195 196 197 |
# File 'lib/sequel/extensions/async_thread_pool.rb', line 195 def self.create_finalizer(queue, pool) proc{run_finalizer(queue, pool)} end |
Instance Method Details
#join ⇒ Object
Join the thread, should only be called by the related finalizer.
224 225 226 |
# File 'lib/sequel/extensions/async_thread_pool.rb', line 224 def join @thread.join end |