Sha256: f0811a6fb834f6d5209991aaf8bd18f5a07ce93456c36878a762503788cd7952
Contents?: true
Size: 1.31 KB
Versions: 3
Compression:
Stored size: 1.31 KB
Contents
module Vedeu module Runtime # Provides the main loop for a Vedeu application. # class MainLoop trap('SIGTERM') { stop! } trap('TERM') { stop! } trap('INT') { stop! } class << self # :nocov: # Start the main loop. # # @return [void] # @yieldreturn [void] The client application. def start! @started = true @loop = true while @loop yield Vedeu::Terminal::Buffer.render safe_exit_point! end rescue Vedeu::Error::Interrupt Vedeu.log(type: :info, message: 'Vedeu execution interrupted, exiting.') end # :nocov: # 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: end # Eigenclass end # MainLoop end # Runtime end # Vedeu
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.6.12 | lib/vedeu/runtime/main_loop.rb |
vedeu-0.6.11 | lib/vedeu/runtime/main_loop.rb |
vedeu-0.6.10 | lib/vedeu/runtime/main_loop.rb |