Class: Proxy::Dynflow::Ticker

Inherits:
Dynflow::Actor
  • Object
show all
Defined in:
lib/smart_proxy_dynflow/ticker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(clock, logger, refresh_interval) ⇒ Ticker

Returns a new instance of Ticker.



9
10
11
12
13
14
15
# File 'lib/smart_proxy_dynflow/ticker.rb', line 9

def initialize(clock, logger, refresh_interval)
  @clock = clock
  @logger = logger
  @events = []
  @refresh_interval = refresh_interval
  plan_next_tick
end

Instance Attribute Details

#clockObject (readonly)

Returns the value of attribute clock.



7
8
9
# File 'lib/smart_proxy_dynflow/ticker.rb', line 7

def clock
  @clock
end

Instance Method Details

#add_event(target, args) ⇒ Object



28
29
30
31
# File 'lib/smart_proxy_dynflow/ticker.rb', line 28

def add_event(target, args)
  @events << [target, args]
  plan_next_tick
end

#tickObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/smart_proxy_dynflow/ticker.rb', line 17

def tick
  @logger.debug("Ticker ticking for #{@events.size} events")
  @events.each do |(target, args)|
    pass_event(target, args)
  end
  @events = []
ensure
  @planned = false
  plan_next_tick
end