1 ! Copyright (C) 2012 Eungju PARK.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: byte-arrays calendar destructors formatting io kernel
4 math namespaces random threads zeromq zeromq.ffi ;
5 IN: zeromq.examples.taskvent
12 ! Socket to send messages on
13 ZMQ_PUSH <zmq-socket> &dispose
14 dup "tcp://*:5557" zmq-bind
16 ! Socket to send start of batch message on
17 ZMQ_PUSH <zmq-socket> &dispose
18 dup "tcp://localhost:5558" zmq-connect
21 "Press Enter when the workers are ready: " write flush
23 "Sending tasks to workers…\n" write flush
25 ! The first message is "0" and signals start of batch
26 dup "0" >byte-array 0 zmq-send
30 ! Random workload from 1 to 100msecs
33 pickd "%d" sprintf >byte-array 0 zmq-send
35 "Total expected cost: %d msec\n" printf
37 ! Give 0MQ time to deliver