64
64
#define ZMQ_NULLPTR nullptr
65
65
#define ZMQ_CONSTEXPR_FN constexpr
66
66
#define ZMQ_CONSTEXPR_VAR constexpr
67
+ #define ZMQ_CPP11_DEPRECATED (msg ) ZMQ_DEPRECATED(msg)
67
68
#else
68
69
#define ZMQ_NOTHROW throw ()
69
70
#define ZMQ_EXPLICIT
70
71
#define ZMQ_OVERRIDE
71
72
#define ZMQ_NULLPTR 0
72
73
#define ZMQ_CONSTEXPR_FN
73
74
#define ZMQ_CONSTEXPR_VAR const
75
+ #define ZMQ_CPP11_DEPRECATED (msg )
74
76
#endif
75
77
76
78
#include < zmq.h>
@@ -630,6 +632,27 @@ inline void swap(message_t &a, message_t &b) ZMQ_NOTHROW
630
632
a.swap (b);
631
633
}
632
634
635
+ #ifdef ZMQ_CPP11
636
+ enum class ctxopt
637
+ {
638
+ blocky = ZMQ_BLOCKY,
639
+ io_threads = ZMQ_IO_THREADS,
640
+ thread_sched_policy = ZMQ_THREAD_SCHED_POLICY,
641
+ thread_priority = ZMQ_THREAD_PRIORITY,
642
+ thread_affinity_cpu_add = ZMQ_THREAD_AFFINITY_CPU_ADD,
643
+ thread_affinity_cpu_remove = ZMQ_THREAD_AFFINITY_CPU_REMOVE,
644
+ thread_name_prefix = ZMQ_THREAD_NAME_PREFIX,
645
+ max_msgsz = ZMQ_MAX_MSGSZ,
646
+ #ifdef ZMQ_ZERO_COPY_RECV
647
+ zero_copy_recv = ZMQ_ZERO_COPY_RECV,
648
+ #endif
649
+ max_sockets = ZMQ_MAX_SOCKETS,
650
+ socket_limit = ZMQ_SOCKET_LIMIT,
651
+ ipv6 = ZMQ_IPV6,
652
+ msg_t_size = ZMQ_MSG_T_SIZE
653
+ };
654
+ #endif
655
+
633
656
class context_t
634
657
{
635
658
public:
@@ -664,16 +687,38 @@ class context_t
664
687
}
665
688
#endif
666
689
690
+ ~context_t () ZMQ_NOTHROW { close (); }
691
+
692
+ ZMQ_CPP11_DEPRECATED (" from 4.7.0, use set taking zmq::ctxopt instead" )
667
693
int setctxopt (int option_, int optval_)
668
694
{
669
695
int rc = zmq_ctx_set (ptr, option_, optval_);
670
696
ZMQ_ASSERT (rc == 0 );
671
697
return rc;
672
698
}
673
699
700
+ ZMQ_CPP11_DEPRECATED (" from 4.7.0, use get taking zmq::ctxopt instead" )
674
701
int getctxopt (int option_) { return zmq_ctx_get (ptr, option_); }
675
702
676
- ~context_t () ZMQ_NOTHROW { close (); }
703
+ #ifdef ZMQ_CPP11
704
+ void set (ctxopt option, int optval)
705
+ {
706
+ int rc = zmq_ctx_set (ptr, static_cast <int >(option), optval);
707
+ if (rc == -1 )
708
+ throw error_t ();
709
+ }
710
+
711
+ ZMQ_NODISCARD int get (ctxopt option)
712
+ {
713
+ int rc = zmq_ctx_get (ptr, static_cast <int >(option));
714
+ // some options have a default value of -1
715
+ // which is unfortunate, and may result in errors
716
+ // that don't make sense
717
+ if (rc == -1 )
718
+ throw error_t ();
719
+ return rc;
720
+ }
721
+ #endif
677
722
678
723
// Terminates context (see also shutdown()).
679
724
void close () ZMQ_NOTHROW
@@ -1266,9 +1311,7 @@ class socket_base
1266
1311
1267
1312
bool connected () const ZMQ_NOTHROW { return (_handle != ZMQ_NULLPTR); }
1268
1313
1269
- #ifdef ZMQ_CPP11
1270
- ZMQ_DEPRECATED (" from 4.3.1, use send taking a const_buffer and send_flags" )
1271
- #endif
1314
+ ZMQ_CPP11_DEPRECATED (" from 4.3.1, use send taking a const_buffer and send_flags" )
1272
1315
size_t send (const void *buf_, size_t len_, int flags_ = 0 )
1273
1316
{
1274
1317
int nbytes = zmq_send (_handle, buf_, len_, flags_);
@@ -1279,9 +1322,7 @@ class socket_base
1279
1322
throw error_t ();
1280
1323
}
1281
1324
1282
- #ifdef ZMQ_CPP11
1283
- ZMQ_DEPRECATED (" from 4.3.1, use send taking message_t and send_flags" )
1284
- #endif
1325
+ ZMQ_CPP11_DEPRECATED (" from 4.3.1, use send taking message_t and send_flags" )
1285
1326
bool send (message_t &msg_,
1286
1327
int flags_ = 0 ) // default until removed
1287
1328
{
@@ -1294,10 +1335,9 @@ class socket_base
1294
1335
}
1295
1336
1296
1337
template <typename T>
1297
- #ifdef ZMQ_CPP11
1298
- ZMQ_DEPRECATED (" from 4.4.1, use send taking message_t or buffer (for contiguous "
1299
- " ranges), and send_flags" )
1300
- #endif
1338
+ ZMQ_CPP11_DEPRECATED (
1339
+ " from 4.4.1, use send taking message_t or buffer (for contiguous "
1340
+ " ranges), and send_flags" )
1301
1341
bool send (T first, T last, int flags_ = 0 )
1302
1342
{
1303
1343
zmq::message_t msg (first, last);
@@ -1310,9 +1350,7 @@ class socket_base
1310
1350
}
1311
1351
1312
1352
#ifdef ZMQ_HAS_RVALUE_REFS
1313
- #ifdef ZMQ_CPP11
1314
- ZMQ_DEPRECATED (" from 4.3.1, use send taking message_t and send_flags" )
1315
- #endif
1353
+ ZMQ_CPP11_DEPRECATED (" from 4.3.1, use send taking message_t and send_flags" )
1316
1354
bool send(message_t &&msg_,
1317
1355
int flags_ = 0 ) // default until removed
1318
1356
{
@@ -1352,9 +1390,8 @@ class socket_base
1352
1390
}
1353
1391
#endif
1354
1392
1355
- #ifdef ZMQ_CPP11
1356
- ZMQ_DEPRECATED (" from 4.3.1, use recv taking a mutable_buffer and recv_flags" )
1357
- #endif
1393
+ ZMQ_CPP11_DEPRECATED (
1394
+ " from 4.3.1, use recv taking a mutable_buffer and recv_flags" )
1358
1395
size_t recv (void *buf_, size_t len_, int flags_ = 0 )
1359
1396
{
1360
1397
int nbytes = zmq_recv (_handle, buf_, len_, flags_);
@@ -1365,10 +1402,8 @@ class socket_base
1365
1402
throw error_t ();
1366
1403
}
1367
1404
1368
- #ifdef ZMQ_CPP11
1369
- ZMQ_DEPRECATED (
1405
+ ZMQ_CPP11_DEPRECATED (
1370
1406
" from 4.3.1, use recv taking a reference to message_t and recv_flags" )
1371
- #endif
1372
1407
bool recv (message_t *msg_, int flags_ = 0 )
1373
1408
{
1374
1409
int nbytes = zmq_msg_recv (msg_->handle (), _handle, flags_);
0 commit comments