Skip to content

Instantly share code, notes, and snippets.

@rizzatti
Created August 8, 2012 18:40
Show Gist options
  • Save rizzatti/3297412 to your computer and use it in GitHub Desktop.
Save rizzatti/3297412 to your computer and use it in GitHub Desktop.
require "eventmachine"
EM.kqueue = true
EM.threadpool_size = 3
EM.run do
count = 0
(1..50).each do |i|
blk = proc do
sleep 2
puts "#{i}\n"
i
end
callback = proc { |result| count += 1; puts "called #{result}" }
EM.defer(blk, callback)
end
EM.instance_exec do
p @threadqueue
end
EM.add_periodic_timer(1) { puts "count e #{count}" }
EM.add_timer(10) { EM.stop }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment