Sha256: 0aa27ef0af8302ada5e71ee0dd51cad9f25f13fdc9945c28a1cc6ce6dea8f20b
Contents?: true
Size: 1.06 KB
Versions: 11
Compression:
Stored size: 1.06 KB
Contents
require 'thread' module OrigenSim class Heartbeat < Thread attr_reader :socket, :simulation # Can't use this with threads currently because Byebug pauses the sleep, # during a breakpoint, which means that the simulator is killed. # Currently working around via a forked process implementation instead # whenever this is set to false. THREADSAFE = false def initialize(simulation, socket) @simulation = simulation @socket = socket @continue = true super do while @continue begin socket.write("OK\n") rescue Errno::EPIPE => e exit 0 if simulation.ended if simulation.monitor_running? Origen.log.error 'Communication with the simulation monitor has been lost (though it seems to still be running)!' else Origen.log.error 'The simulation monitor has stopped unexpectedly!' end exit 1 end sleep 5 end end end def stop @continue = false end end end
Version data entries
11 entries across 11 versions & 1 rubygems