Event signaling between methods of the same object
Run the given task, reporting errors that occur
# File lib/celluloid/signals.rb, line 45 def run_task(task, value) task.resume(value) rescue => ex Logger.crash("signaling error", ex) end
Send a signal to all method calls waiting for the given name Returns true if any calls were signaled, or false otherwise
# File lib/celluloid/signals.rb, line 29 def send(name, value = nil) tasks = @waiting.delete name case tasks when Array tasks.each { |task| run_task task, value } true if tasks.size > 0 when NilClass false else run_task tasks, value true end end
Wait for the given signal and return the associated value
# File lib/celluloid/signals.rb, line 11 def wait(signal) raise "cannot wait for signals while exclusive" if Celluloid.exclusive? tasks = @waiting[signal] case tasks when Array tasks << Task.current when NilClass @waiting[signal] = Task.current else @waiting[signal] = [tasks, Task.current] end Task.suspend :sigwait end
Generated with the Darkfish Rdoc Generator 2.