Skip to content

Instantly share code, notes, and snippets.

@derekharmel
Created July 9, 2012 16:10
Show Gist options
  • Save derekharmel/3077371 to your computer and use it in GitHub Desktop.
Save derekharmel/3077371 to your computer and use it in GitHub Desktop.
Eventmachine and FiberIterator processing N requests per second with variable concurrency
require 'rubygems'
require 'em-synchrony'
require 'em-synchrony/fiber_iterator'
EM.synchrony do
values = (1..16).to_a
{a: 2, b: 4, c: 8}.each do |label,concurrency|
print "\n #{label}"
EM::Synchrony::FiberIterator.new(values, concurrency).each do |val|
print " #{val}"
EM::Synchrony.sleep(1)
end
end
EM.stop
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment