Skip to content

Commit 7aa3f37

Browse files
committed
Problem: poll default timeout is deprecated
Solution: default to std::chrono::milliseconds
1 parent 4108a5d commit 7aa3f37

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

zmq.hpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,12 @@ class error_t : public std::exception
299299
int errnum;
300300
};
301301

302+
#ifdef ZMQ_CPP11
303+
ZMQ_DEPRECATED("from 4.8.0, use poll taking std::chrono::duration instead of long")
304+
inline int poll(zmq_pollitem_t *items_, size_t nitems_, long timeout_)
305+
#else
302306
inline int poll(zmq_pollitem_t *items_, size_t nitems_, long timeout_ = -1)
307+
#endif
303308
{
304309
int rc = zmq_poll(items_, static_cast<int>(nitems_), timeout_);
305310
if (rc < 0)
@@ -337,19 +342,19 @@ inline int poll(std::vector<zmq_pollitem_t> const &items, long timeout_ = -1)
337342
}
338343

339344
inline int
340-
poll(zmq_pollitem_t *items, size_t nitems, std::chrono::milliseconds timeout)
345+
poll(zmq_pollitem_t *items, size_t nitems, std::chrono::milliseconds timeout = std::chrono::milliseconds{-1})
341346
{
342347
return poll(items, nitems, static_cast<long>(timeout.count()));
343348
}
344349

345350
inline int poll(std::vector<zmq_pollitem_t> &items,
346-
std::chrono::milliseconds timeout)
351+
std::chrono::milliseconds timeout = std::chrono::milliseconds{-1})
347352
{
348353
return poll(items.data(), items.size(), static_cast<long>(timeout.count()));
349354
}
350355

351-
ZMQ_DEPRECATED("from 4.3.1, use poll taking std::chrono instead of long")
352-
inline int poll(std::vector<zmq_pollitem_t> &items, long timeout_ = -1)
356+
ZMQ_DEPRECATED("from 4.3.1, use poll taking std::chrono::duration instead of long")
357+
inline int poll(std::vector<zmq_pollitem_t> &items, long timeout_)
353358
{
354359
return poll(items.data(), items.size(), timeout_);
355360
}

0 commit comments

Comments
 (0)