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.
208 209 210 211 212 213 214 |
# File 'lib/sequel/extensions/async_thread_pool.rb', line 208 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:
188 189 190 |
# File 'lib/sequel/extensions/async_thread_pool.rb', line 188 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.
217 218 219 |
# File 'lib/sequel/extensions/async_thread_pool.rb', line 217 def join @thread.join end |