-
-
Save havenwood/7f4efb00ec2b4a5c19ce89a536bbbd91 to your computer and use it in GitHub Desktop.
This file contains 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
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