Sha256: d727f63f7c76f325a9f2c9651ee7c2c208c11916f32bdb40e0137d9af247354a

Contents?: true

Size: 543 Bytes

Versions: 6

Compression:

Stored size: 543 Bytes

Contents

require 'rubygems'
require 'bundler/setup'
require 'uvrb'

start = Time.now

loop = UV.default_loop

timer = UV.create_handle(:uv_timer)
# timer = FFI::MemoryPointer.new(UV::Timer, UV::Timer.size, 1)
count = 0
UV.timer_init(loop, timer)
$stdout << "\r\n"

close_cb = proc {|ptr| UV.free(ptr); $stdout << "\n"; }

timer_cb = Proc.new do |ptr, status|
  $stdout << "#{count}\r"
  if count >= 10000
    UV.close(ptr, close_cb)
  end
  count += 1
end

UV.timer_start(timer, timer_cb, 1, 1)
UV.run(loop)
UV.loop_delete(loop)

puts Time.now - start

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
uvrb-0.2.0 examples/example.rb
uvrb-0.1.4 examples/example.rb
uvrb-0.1.3 examples/example.rb
uvrb-0.1.2 examples/example.rb
uvrb-0.1.1 examples/example.rb
uvrb-0.1.0 examples/example.rb