Sha256: adb2f68b2f3bc77f83bd64c3e851f6c9f56cc4ca3ca0c74411ea1dccd105dcbd
Contents?: true
Size: 900 Bytes
Versions: 12
Compression:
Stored size: 900 Bytes
Contents
module God class Trigger class << self attr_accessor :triggers # {task.name => condition} end # init self.triggers = {} @mutex = Mutex.new def self.register(condition) @mutex.synchronize do self.triggers[condition.watch.name] ||= [] self.triggers[condition.watch.name] << condition end end def self.deregister(condition) @mutex.synchronize do self.triggers[condition.watch.name].delete(condition) self.triggers.delete(condition.watch.name) if self.triggers[condition.watch.name].empty? end end def self.broadcast(task, message, payload) return unless self.triggers[task.name] @mutex.synchronize do self.triggers[task.name].each do |t| t.process(message, payload) end end end def self.reset self.triggers.clear end end end
Version data entries
12 entries across 12 versions & 3 rubygems