Created
July 14, 2013 01:42
-
-
Save keithpitt/5992871 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'celluloid' | |
class Thingy | |
include Celluloid | |
def initialize(name) | |
@name = name | |
end | |
def start | |
puts "begin #{@name}" | |
sleep 3 | |
puts "done #{@name}" | |
terminate | |
end | |
end | |
actors = [] | |
3.times do | |
actors << runner = Thingy.new("keith") | |
runner.async.start | |
end | |
until actors.select(&:alive?).empty? | |
sleep 0.5 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The goal is to wait for all the actors to finish their task.