Created
July 9, 2012 16:10
-
-
Save derekharmel/3077371 to your computer and use it in GitHub Desktop.
Eventmachine and FiberIterator processing N requests per second with variable concurrency
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 '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