Class: Termplot::Consumers::BaseConsumer
- Inherits:
-
Object
- Object
- Termplot::Consumers::BaseConsumer
- Defined in:
- lib/termplot/consumers/base_consumer.rb
Direct Known Subclasses
Defined Under Namespace
Classes: ProducerPool, RendererThread
Instance Method Summary collapse
-
#initialize(options) ⇒ BaseConsumer
constructor
A new instance of BaseConsumer.
- #run ⇒ Object
Constructor Details
#initialize(options) ⇒ BaseConsumer
Returns a new instance of BaseConsumer.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/termplot/consumers/base_consumer.rb', line 10 def initialize() @options = @broker_pool = MessageBrokerPool.new @producer_pool = ProducerPool.new @renderer = Renderer.new( cols: .cols, rows: .rows, widgets: , debug: .debug ) @renderer_thread = RendererThread.new( renderer: renderer, broker_pool: broker_pool ) end |
Instance Method Details
#run ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/termplot/consumers/base_consumer.rb', line 27 def run register_producers_and_brokers broker_pool. { renderer_thread.continue } Shell.init(clear: .full_screen) renderer_thread.start # Blocks main thread to produce values from the producer pool producer_pool.start_and_block # At this point producer threads have all exited, tell renderer to # consume all messages left on the queue renderer_thread.continue while !broker_pool.empty? # Close queues broker_pool.shutdown # Shutdown renderer renderer_thread.join end |