Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created December 23, 2019 21:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/7f4efb00ec2b4a5c19ce89a536bbbd91 to your computer and use it in GitHub Desktop.
Save havenwood/7f4efb00ec2b4a5c19ce89a536bbbd91 to your computer and use it in GitHub Desktop.
require 'async'
reactor = Async::Reactor.new
reactor.async do |task|
task.async do |subtask|
loop do
puts 'ping'
subtask.sleep 3
end
end
task.async do |subtask|
loop do
puts 'pong'
subtask.sleep 4
end
end
end
reactor.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment