lib/vedeu/runtime/main_loop.rb in vedeu-0.6.7 vs lib/vedeu/runtime/main_loop.rb in vedeu-0.6.8
- old
+ new
@@ -1,55 +1,60 @@
module Vedeu
- # Provides the main loop for a Vedeu application.
- #
- class MainLoop
+ module Runtime
- trap('SIGTERM') { stop! }
- trap('TERM') { stop! }
- trap('INT') { stop! }
+ # Provides the main loop for a Vedeu application.
+ #
+ class MainLoop
- class << self
+ trap('SIGTERM') { stop! }
+ trap('TERM') { stop! }
+ trap('INT') { stop! }
- # :nocov:
- # Start the main loop.
- #
- # @return [void]
- # @yieldreturn [void] The client application.
- def start!
- @started = true
- @loop = true
+ class << self
- while @loop
- yield
+ # :nocov:
+ # Start the main loop.
+ #
+ # @return [void]
+ # @yieldreturn [void] The client application.
+ def start!
+ @started = true
+ @loop = true
- safe_exit_point!
+ while @loop
+ yield
+
+ safe_exit_point!
+ end
+ rescue Vedeu::Error::Interrupt
+ Vedeu.log(type: :info,
+ message: 'Vedeu execution interrupted, exiting.')
end
- rescue Vedeu::Error::Interrupt
- Vedeu.log(type: :info,
- message: 'Vedeu execution interrupted, exiting.')
- end
- # :nocov:
+ # :nocov:
- # Signal that we wish to terminate the running application.
- #
- # @return [void]
- def stop!
- @loop = false
- end
+ # Signal that we wish to terminate the running application.
+ #
+ # @return [void]
+ def stop!
+ @loop = false
+ end
- # :nocov:
- # Check the application has started and we wish to continue running.
- #
- # @raise [Vedeu::Error::Interrupt] When we wish to terminate the running
- # application.
- # @return [void]
- def safe_exit_point!
- fail Vedeu::Error::Interrupt if @started && !@loop
- end
- # :nocov:
+ # :nocov:
+ # Check the application has started and we wish to continue
+ # running.
+ #
+ # @raise [Vedeu::Error::Interrupt] When we wish to terminate
+ # the running application.
+ # @return [void]
+ def safe_exit_point!
+ fail Vedeu::Error::Interrupt if @started && !@loop
+ end
+ # :nocov:
- end # Eigenclass
+ end # Eigenclass
- end # MainLoop
+ end # MainLoop
+
+ end # Runtime
end # Vedeu