Created
January 7, 2014 04:07
-
-
Save chikadance/8294503 to your computer and use it in GitHub Desktop.
cells communication
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
require 'celluloid' | |
class C | |
include Celluloid | |
def wait(c) | |
if c.attr >= 200 | |
puts "c.attr >= 200" | |
return "finished" | |
end | |
end | |
attr_accessor :attr | |
def attr | |
@attr ||= 0 | |
end | |
def m | |
200.times do | |
self.attr += 1 | |
end | |
end | |
end | |
C.supervise_as("c1") | |
C.supervise_as("c2") | |
while 1 do | |
Celluloid::Actor["c2"].async.m | |
future = Celluloid::Actor["c1"].future.wait(Celluloid::Actor["c2"]) | |
p future | |
if future.value == "finished" | |
break | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment