I recommend using the Observer pattern. Celluloid supports this through Notifications. Take a look at the wiki for some info: https://github.com/celluloid/celluloid/wiki/Notifications
Here is an example of working code:
require 'rubygems' require 'celluloid/autostart' class Test include Celluloid include Celluloid::Notifications def initialize(aaa) @aaa = aaa end def foo sleep 2 @bbb = 'asdasd' publish "done!", "Slept for 2 seconds and set @bbb = #{@bbb}" end def bar "aaa is: #{@aaa}, bbb is: #{@bbb}" end end class Observer include Celluloid include Celluloid::Notifications def initialize subscribe "done!", :on_completion end def on_completion(*args) puts "finished, returned #{args.inspect}" end end y = Observer.new x = Test.new 111 x.async.foo sleep 3
source share