Class: Canopus::DisplayMap::Worker
- Inherits:
-
Object
- Object
- Canopus::DisplayMap::Worker
- Defined in:
- lib/canopus/display_map/worker.rb
Defined Under Namespace
Constant Summary collapse
- BATCH_LINES =
32- QUEUE_LIMIT =
8
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize ⇒ Worker
constructor
A new instance of Worker.
- #submit(generation, tree, builder, prefix) ⇒ Object
Constructor Details
#initialize ⇒ Worker
Returns a new instance of Worker.
12 13 14 15 16 17 |
# File 'lib/canopus/display_map/worker.rb', line 12 def initialize @requests, @results = Queue.new, SizedQueue.new(QUEUE_LIMIT) @thread = Thread.new { run } @thread.name = "canopus-wrap" @thread.report_on_exception = false end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
10 11 12 |
# File 'lib/canopus/display_map/worker.rb', line 10 def results @results end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
10 11 12 |
# File 'lib/canopus/display_map/worker.rb', line 10 def thread @thread end |
Instance Method Details
#close ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/canopus/display_map/worker.rb', line 26 def close return if @closed @closed = true @generation = nil @requests.close @results.close # Cancellation checkpoints normally finish in milliseconds. No native # resource or shared mutable document state belongs to this worker. @thread.kill unless @thread.join(1) @thread.join(0.1) @results.clear end |