Sha256: 31203a0ebea36b75fb5b7eeb742b64cf1a1baa882a16dc9624877aac199511f9

Contents?: true

Size: 768 Bytes

Versions: 4

Compression:

Stored size: 768 Bytes

Contents

# encoding: utf-8

# Task sink to be used in conjunction with task_vent.rb
# and task_worker.rb
# Binds PULL socket to tcp://localhost:5558
# Collects results from task_workers via that socket

require File.join(File.dirname(__FILE__), '..', 'lib', 'ffi-rxs')

# Prepare our context and socket
context = XS::Context.create()
receiver = context.socket(XS::PULL)
receiver.bind("tcp://*:5558")

# Wait for start of batch
receiver.recv_string('')
puts 'Sink started'
tstart = Time.now

# Process 100 confirmations
100.times do |task_nbr|
  receiver.recv_string('')
  $stdout << ((task_nbr % 10 == 0) ? ':' : '.')
  $stdout.flush
end

# Calculate and report duration of batch
tend = Time.now
total_msec = (tend-tstart) * 1000
puts "Total elapsed time: #{total_msec} msec"

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ffi-rxs-1.2.1 examples/task_sink.rb
ffi-rxs-1.2.0 examples/task_sink.rb
ffi-rxs-1.1.0 examples/task_sink.rb
ffi-rxs-1.0.1 examples/task_sink.rb