Skip to content

Instantly share code, notes, and snippets.

@e0da
Created September 27, 2012 00:29
Show Gist options
  • Save e0da/3791473 to your computer and use it in GitHub Desktop.
Save e0da/3791473 to your computer and use it in GitHub Desktop.
class Actor
def ping
puts "#{self.class.name}:ping"
end
end
class SinatraApp < Actor
def run
loop do
puts :whoa?
sleep 2
end
end
end
class BigBrother < Actor
def run
loop do
puts :whee
sleep 3
end
end
end
class Runner
def initialize
@sinatra = SinatraApp.new
@big_brother = BigBrother.new
@threads = []
@threads << Thread.new { @sinatra.run }
@threads << Thread.new { @big_brother.run }
@threads << Thread.new { monitor }
@threads.each {|t| t.join}
end
def monitor
loop do
@sinatra.ping
@big_brother.ping
sleep 1
end
end
end
Runner.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment