Sha256: 0f9697b53106d9adf4abb76f14dc33776848bbc890833003b1b52fab2d21cb54

Contents?: true

Size: 863 Bytes

Versions: 4

Compression:

Stored size: 863 Bytes

Contents

# encoding: utf-8

#   Task worker to be used in conjunction with task_vent.rb
#   and task_sink.rb
#   Connects PULL socket to tcp://localhost:5557
#   Collects workloads from task_vent via that socket
#   Connects PUSH socket to tcp://localhost:5558
#   Sends results to sink via that socket

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

context = XS::Context.create()

# Socket to receive messages on
receiver = context.socket(XS::PULL)
receiver.connect("tcp://localhost:5557")

# Socket to send messages to
sender = context.socket(XS::PUSH)
sender.connect("tcp://localhost:5558")

# Process tasks forever
while true
  
  receiver.recv_string(msec = '')
  # Simple progress indicator for the viewer
  $stdout << "#{msec}."
  $stdout.flush

  # Do the work
  sleep(msec.to_f / 1000)

  # Send results to sink
  sender.send_string("")
end

Version data entries

4 entries across 4 versions & 1 rubygems

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