Sha256: c17144c973f1b374c49e86716f8df94834690984a64e486eaa185167556e3cf5
Contents?: true
Size: 1.19 KB
Versions: 4
Compression:
Stored size: 1.19 KB
Contents
module Vedeu # Provides the main loop for a Vedeu application. # # Each time Vedeu starts one cycle in the application loop, it triggers the # `:tick` event. A completion of that cycle will trigger `:tock`. This can be # used by the client application for timing amongst other things. # class MainLoop trap('SIGTERM') { stop! } trap('TERM') { stop! } trap('INT') { stop! } # :nocov: # Start the main loop. # # @param block [Proc] # @return [void] def self.start!(&block) @started = true @loop = true while(@loop) do yield safe_exit_point! end rescue VedeuInterrupt end # :nocov: # Signal that we wish to terminate the running application. # # @return [void] def self.stop! @loop = false end private # Check the application has started and we wish to continue running. # # @raise [VedeuInterrupt] When we wish to terminate the running application. # @return [void] def self.safe_exit_point! if @started && !@loop fail VedeuInterrupt else Vedeu.trigger(:tock, Time.now.to_f) end end end # MainLoop end # Vedeu
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.4.13 | lib/vedeu/main_loop.rb |
vedeu-0.4.12 | lib/vedeu/main_loop.rb |
vedeu-0.4.11 | lib/vedeu/main_loop.rb |
vedeu-0.4.10 | lib/vedeu/main_loop.rb |