forked from booksbyus/zguide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
taskwork.fsx
39 lines (30 loc) · 815 Bytes
/
taskwork.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(*
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
*)
#r @"bin/fszmq.dll"
open fszmq
#load "zhelpers.fs"
let main () =
use context = new Context(1)
// Socket to receive messages on
use receiver = context |> Context.pull
Socket.connect receiver "tcp://localhost:5557"
// Socket to send messages to
use sender = context |> Context.push
Socket.connect sender "tcp://localhost:5558"
// Process tasks forever
while true do
let msg = s_recv receiver
// Simple progress indicator for the viewer
fflush()
printf "%s." msg
// Do the work
sleep (int msg)
// Send results to sink
s_send sender ""
EXIT_SUCCESS
main ()