Class: DerivedImages::Worker
- Inherits:
-
Object
- Object
- DerivedImages::Worker
- Defined in:
- lib/derived_images/worker.rb
Overview
A Worker represents a thread in a thread pool that completes image creation tasks.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(queue, cache = Cache.new) ⇒ Worker
constructor
A new instance of Worker.
- #run ⇒ Object
Constructor Details
Class Method Details
.start(thread_group, queue) ⇒ Object
18 19 20 21 |
# File 'lib/derived_images/worker.rb', line 18 def self.start(thread_group, queue) DerivedImages.config.logger.debug('Starting a new worker thread') thread_group.add(Thread.new { Worker.new(queue).run }) end |
Instance Method Details
#run ⇒ Object
11 12 13 14 15 16 |
# File 'lib/derived_images/worker.rb', line 11 def run until queue.closed? && queue.empty? entry = queue.pop process(entry) if entry end end |