Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brainopia/618701 to your computer and use it in GitHub Desktop.
Save brainopia/618701 to your computer and use it in GitHub Desktop.
require 'em-synchrony'
require 'em-synchrony/em-http'
require 'em-synchrony/iterator'
=begin
Currently Synchrony::Iterator does not support synced calls inside,
but it can by integrating fiber pool inside.
It even makes more sense for concurrency option of Iterator to be fiber pool size.
=end
EM.run do
urls = Array.new(5, 'http://ya.ru')
EM::Synchrony::Iterator.new(urls, 5).each do
# currently fails with "yield from root fiber"
EM::HttpRequest.new(url).get # or any other synced evented call
puts '+1'
end
EM.stop
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment