Class: Termplot::Consumers::BaseConsumer::RendererThread
- Inherits:
-
Object
- Object
- Termplot::Consumers::BaseConsumer::RendererThread
- Defined in:
- lib/termplot/consumers/base_consumer.rb
Instance Method Summary collapse
- #continue ⇒ Object
-
#initialize(renderer:, broker_pool:, &block) ⇒ RendererThread
constructor
A new instance of RendererThread.
- #join ⇒ Object
- #pause ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(renderer:, broker_pool:, &block) ⇒ RendererThread
Returns a new instance of RendererThread.
56 57 58 59 60 61 |
# File 'lib/termplot/consumers/base_consumer.rb', line 56 def initialize(renderer:, broker_pool:, &block) @renderer = renderer @broker_pool = broker_pool @block = block @thread = nil end |
Instance Method Details
#continue ⇒ Object
83 84 85 |
# File 'lib/termplot/consumers/base_consumer.rb', line 83 def continue thread.run end |
#join ⇒ Object
91 92 93 |
# File 'lib/termplot/consumers/base_consumer.rb', line 91 def join thread.join unless thread.stop? end |
#pause ⇒ Object
87 88 89 |
# File 'lib/termplot/consumers/base_consumer.rb', line 87 def pause Thread.stop end |
#start ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/termplot/consumers/base_consumer.rb', line 63 def start @thread = Thread.new do # Pause and wait to be woken for rendering pause while !broker_pool.closed? num_samples = broker_pool. if num_samples.zero? pause else broker_pool. if num_samples > 0 renderer.render end end end end end |