Sha256: 5e0c3e53065130c774cb096d6195f7245ab353673daaa4104617e8f9f65c3aa3
Contents?: true
Size: 597 Bytes
Versions: 5
Compression:
Stored size: 597 Bytes
Contents
module Agent class Notifier attr_reader :payload def initialize @mutex = Mutex.new @cvar = ConditionVariable.new @notified = false @payload = nil end def notified? @notified end def wait @mutex.synchronize do until notified? @cvar.wait(@mutex) end end end def notify(payload) @mutex.synchronize do return Error.new("already notified") if notified? @payload = payload @notified = true @cvar.signal return nil end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
agent-0.12.0 | lib/agent/notifier.rb |
agent-0.11.0 | lib/agent/notifier.rb |
agent-0.10.0 | lib/agent/notifier.rb |
agent-0.9.1 | lib/agent/notifier.rb |
agent-0.9.0 | lib/agent/notifier.rb |