# Author:: Nicolas Despres . # Copyright:: Copyright (c) 2004, 2005 TTK team. All rights reserved. # License:: LGPL # $Id: Monitor.rb 567 2005-04-13 08:00:06Z polrop $ require 'drb/drb_observable' require 'timeout' module TTK module Monitors class Monitor include DRb::DRbObservable NOTIFICATION_TIMEOUT = 5 def initialize @notify_q = Queue.new @thread = Thread.new do loop do observable, msg_type, *infos = @notify_q.pop begin timeout(NOTIFICATION_TIMEOUT) do changed notify_observers(observable.class.to_s, msg_type, Time.now, *infos) end rescue Timeout::Error #FIXME: report this failure somehow to the logger. We need to #know if some buggy monitor client are connected to the server! end end end end def update(*args, &block) @notify_q.push(args) end end # class Monitor end # module Monitors end # module TTK