Module: Ons
- Defined in:
- lib/ons.rb,
lib/ons/lmfao.rb,
lib/ons/version.rb,
lib/ons/consumer.rb,
lib/ons/producer.rb
Overview
.
Defined Under Namespace
Modules: LMFAO Classes: Consumer, Producer
Constant Summary collapse
- VERSION =
'1.0.2'.freeze
Class Method Summary collapse
-
.loop_forever ⇒ Object
Block the current thread.
-
.register_cleanup_hooks ⇒ Object
Perform an automatic cleanup at program exit.
Class Method Details
.loop_forever ⇒ Object
Block the current thread.
32 33 34 35 |
# File 'lib/ons.rb', line 32 def self.loop_forever raise 'please start an Ons::Consumer instance before loop forever' if Consumer.instances.empty? LMFAO.event_thread.join end |
.register_cleanup_hooks ⇒ Object
Perform an automatic cleanup at program exit.
It handles:
-
shutdown all the Consumer instances, see also Ons::Consumer#shutdown
-
shutdown all the Producer instances, see also Ons::Producer#shutdown
-
kill the global LMFAO event thread if it’s running
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ons.rb', line 20 def self.register_cleanup_hooks return if @registered @registered = true at_exit do Consumer.instances.each(&:shutdown) Producer.instances.each(&:shutdown) LMFAO.event_thread && LMFAO.event_thread.terminate end end |