Created
August 30, 2017 13:15
-
-
Save tiagopog/9ab59474c8800c413d663fbe23dac120 to your computer and use it in GitHub Desktop.
Event Machine usage example.
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
# em.rb | |
EM.run do | |
EM.add_timer(1) do | |
puts 'sleeping...' | |
EM.system('sleep 1') { puts "woke up!" } | |
puts 'continuing...' | |
end | |
EM.add_timer(3) { EM.stop } | |
end | |
$ ruby em.rb | |
sleeping... | |
continuing... | |
woke up! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment