Sha256: e17e38c3c8ab3b6baa1553e747e92a496369861848aae9c2924364d6ce53cff4
Contents?: true
Size: 937 Bytes
Versions: 69
Compression:
Stored size: 937 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
69 entries across 69 versions & 21 rubygems