Skip to content

Commit 50ea6ba

Browse files
committed
Zmq.hpp
1 parent b808671 commit 50ea6ba

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

section5/Zmq.hpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) 2020 by Chrono
2+
3+
#ifndef _SPIN_LOCK_HPP
4+
#define _SPIN_LOCK_HPP
5+
6+
#include "cpplang.hpp"
7+
8+
#include <zmq.hpp>
9+
10+
BEGIN_NAMESPACE(cpp_study)
11+
12+
template<int thread_num = 1>
13+
class ZmqContext final
14+
{
15+
public:
16+
using zmq_context_type = zmq::context_t;
17+
using zmq_socket_type = zmq::socket_t;
18+
using zmq_message_type = zmq::message_t;
19+
public:
20+
static
21+
zmq_context_type& context()
22+
{
23+
static zmq_context_type ctx(thread_num);
24+
return ctx;
25+
}
26+
public:
27+
zmq_socket_type socket(int mode) const
28+
{
29+
return zmq_socket_type(context(), mode);
30+
}
31+
};
32+
33+
END_NAMESPACE(cpp_study)
34+
35+
#endif //_SPIN_LOCK_HPP
36+

0 commit comments

Comments
 (0)