Created
January 27, 2012 09:33
-
-
Save brainopia/1687971 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
equire 'celluloid' | |
module Observable | |
def start_notifier | |
receive do |it| | |
if it.is_a? Celluloid::Actor | |
wait :done | |
it.signal :notification | |
end | |
end | |
end | |
end | |
class Foo | |
include Celluloid | |
include Observable | |
def initialize | |
start_notifier! | |
end | |
def work | |
sleep 10 | |
puts 'Foo finished' | |
signal :done | |
end | |
end | |
class Bar | |
include Celluloid | |
def work_after(actor) | |
actor.mailbox << self | |
wait :notification | |
puts 'Bar finished' | |
end | |
end | |
foo = Foo.new | |
bar = Bar.new | |
foo.work! | |
bar.work_after foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment