Skip to content

Instantly share code, notes, and snippets.

@keithpitt
Created July 14, 2013 01:42
Show Gist options
  • Save keithpitt/5992871 to your computer and use it in GitHub Desktop.
Save keithpitt/5992871 to your computer and use it in GitHub Desktop.
#!/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
@keithpitt
Copy link
Author

The goal is to wait for all the actors to finish their task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment