Class: TTK::Monitors::Monitor

Inherits:
Object
  • Object
show all
Includes:
DRb::DRbObservable
Defined in:
lib/ttk/monitors/Monitor.rb

Constant Summary collapse

NOTIFICATION_TIMEOUT =
5

Instance Method Summary collapse

Constructor Details

#initializeMonitor

Returns a new instance of Monitor.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ttk/monitors/Monitor.rb', line 20

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

Instance Method Details

#update(*args, &block) ⇒ Object



41
42
43
# File 'lib/ttk/monitors/Monitor.rb', line 41

def update(*args, &block)
  @notify_q.push(args)
end