File: ex_tick_loop_array.rb

package info (click to toggle)
ruby-eventmachine 1.0.3-6%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,000 kB
  • ctags: 3,178
  • sloc: ruby: 8,641; cpp: 5,217; java: 827; makefile: 5
file content (15 lines) | stat: -rw-r--r-- 221 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require File.dirname(__FILE__) + '/helper'

EM.run do
  array = (1..100).to_a

  tickloop = EM.tick_loop do
    if array.empty?
      :stop
    else
      puts array.shift
    end
  end

  tickloop.on_stop { EM.stop }
end