Parallel task worker in Felix

//
// Task worker
// Connects PULL socket to tcp://localhost:5557
// Collects workloads from ventilator via that socket
// Connects PUSH socket to tcp://localhost:5558
// Sends results to sink via that socket

open ZMQ;

var context = zmq_init (1);

// Socket to receive messages on
var receiver = context.mk_socket ZMQ_PULL;
receiver.connect "tcp://localhost:5557";

// Socket to send messages to
var sender = context.mk_socket ZMQ_PUSH;
sender.connect "tcp://localhost:5558";

// Process tasks forever
while true do
var s = receiver.recv_string;
// Simple progress indicator for the viewer
println s; fflush stdout;

// Do the work
Faio::sleep (sys_clock, atof s/1000.0);

// Send results to sink
sender.send_string "";
done