Skip to content

Instantly share code, notes, and snippets.

@brainopia
Created January 27, 2012 09:33
Show Gist options
  • Save brainopia/1687971 to your computer and use it in GitHub Desktop.
Save brainopia/1687971 to your computer and use it in GitHub Desktop.
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