Skip to content

Instantly share code, notes, and snippets.

@chikadance
Created January 7, 2014 04:07
Show Gist options
  • Save chikadance/8294503 to your computer and use it in GitHub Desktop.
Save chikadance/8294503 to your computer and use it in GitHub Desktop.
cells communication
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