File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77
88BEGIN_NAMESPACE (cpp_study)
99
10+ // atomic spinlock with TAS
1011class SpinLock final
1112{
1213public:
@@ -43,6 +44,8 @@ class SpinLock final
4344 atomic_type m_lock {false };
4445};
4546
47+ // RAII for lock
48+ // you can change it to a template class
4649class SpinLockGuard final
4750{
4851public:
Original file line number Diff line number Diff line change @@ -32,23 +32,23 @@ class ZmqContext final
3232 }
3333public:
3434 static
35- zmq_socket_type recv_sock (int hwm = 1000 )
35+ zmq_socket_type recv_sock (int hwm = 1000 , int linger = 10 )
3636 {
3737 zmq_socket_type sock (context (), ZMQ_PULL);
3838
3939 sock.setsockopt (ZMQ_RCVHWM, hwm);
40- sock.setsockopt (ZMQ_LINGER, 10 ); // wait for 10ms
40+ sock.setsockopt (ZMQ_LINGER, linger ); // wait for 10ms
4141
4242 return sock;
4343 }
4444
4545 static
46- zmq_socket_type send_sock (int hwm = 1000 )
46+ zmq_socket_type send_sock (int hwm = 1000 , int linger = 10 )
4747 {
4848 zmq_socket_type sock (context (), ZMQ_PUSH);
4949
5050 sock.setsockopt (ZMQ_SNDHWM, hwm);
51- sock.setsockopt (ZMQ_LINGER, 10 ); // wait for 10ms
51+ sock.setsockopt (ZMQ_LINGER, linger ); // wait for 10ms
5252
5353 return sock;
5454 }
You can’t perform that action at this time.
0 commit comments