Skip to content

Instantly share code, notes, and snippets.

@toshi3221
Created September 24, 2012 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toshi3221/3776052 to your computer and use it in GitHub Desktop.
Save toshi3221/3776052 to your computer and use it in GitHub Desktop.
EM::Iterator sample
def em
EM.run do
EM::Iterator.new(0..10, 3).each(proc{ |num, iter|
(0..(rand(100))).inject(0){|sum,i| sum+=i}
puts num.inspect
iter.next
}, proc{|responses|
puts 'complete!'
EM.stop
})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment