-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathZmqContext.cc
54 lines (45 loc) · 1.02 KB
/
ZmqContext.cc
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
#include "ZmqContext.h"
#include <zmq.h>
#include <stdio.h>
#include <QtGlobal>
ZmqContext *ZmqContext::self_ = 0;
ZmqContext::ZmqContext(int iothreads, int defaultLinger) : linger_(defaultLinger)
{
Q_ASSERT(!self_);
context_ = zmq_init(iothreads);
if(!context_) {
if(errno == EINVAL) {
qFatal("Invalid number of iothreads (%d) in ZmqContext", iothreads);
} else {
qFatal("Error in ZMQContext: %d %s", errno, zmq_strerror(errno));
}
}
}
ZmqContext::~ZmqContext()
{
zmq_term(context_);
}
int ZmqContext::majorVersion()
{
int major, minor, patch;
zmq_version(&major, &minor, &patch);
return major;
}
int ZmqContext::minorVersion()
{
int major, minor, patch;
zmq_version(&major, &minor, &patch);
return minor;
}
int ZmqContext::patchVersion()
{
int major, minor, patch;
zmq_version(&major, &minor, &patch);
return patch;
}
QString ZmqContext::version()
{
int major, minor, patch;
zmq_version(&major, &minor, &patch);
return QString("%1.%2.%3").arg(major).arg(minor).arg(patch);
}