forked from zeromq/clrzmq4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasksink.cs
54 lines (46 loc) · 1.07 KB
/
tasksink.cs
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using ZeroMQ;
namespace Examples
{
static partial class Program
{
public static void TaskSink(string[] args)
{
//
// Task sink
// Binds PULL socket to tcp://127.0.0.1:5558
// Collects results from workers via that socket
//
// Author: metadings
//
// Prepare our context and socket
using (var context = new ZContext())
using (var sink = new ZSocket(context, ZSocketType.PULL))
{
sink.Bind("tcp://*:5558");
// Wait for start of batch
sink.ReceiveFrame();
// Start our clock now
var stopwatch = new Stopwatch();
stopwatch.Start();
// Process 100 confirmations
for (int i = 0; i < 100; ++i)
{
sink.ReceiveFrame();
if ((i / 10) * 10 == i)
Console.Write(":");
else
Console.Write(".");
}
// Calculate and report duration of batch
stopwatch.Stop();
Console.WriteLine("Total elapsed time: {0} ms", stopwatch.ElapsedMilliseconds);
}
}
}
}