Sha256: 66fbcbff622f36cbb1b536628eeb099d5b0b358ea8bde58db626b27b572a12a2
Contents?: true
Size: 663 Bytes
Versions: 1
Compression:
Stored size: 663 Bytes
Contents
module Celluloid # Event signaling between methods of the same object class Signals attr_reader :waiting def initialize @waiting = {} end # Wait for the given signal name and return the associated value def wait(name) tasks = @waiting[name] ||= [] tasks << Task.current Task.suspend end # Send a signal to all method calls waiting for the given name # Returns true if any calls were signaled, or false otherwise def send(name, value = nil) tasks = @waiting.delete name return unless tasks tasks.each { |task| task.resume(value) if task.running? } value end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
celluloid-0.7.0 | lib/celluloid/signals.rb |