mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-29 12:18:04 +01:00
Optimized zmq::dish_t::xrecv
This commit is contained in:
17
src/dish.cpp
17
src/dish.cpp
@@ -178,27 +178,26 @@ int zmq::dish_t::xrecv (msg_t *msg_)
|
|||||||
// If there's already a message prepared by a previous call to zmq_poll,
|
// If there's already a message prepared by a previous call to zmq_poll,
|
||||||
// return it straight ahead.
|
// return it straight ahead.
|
||||||
if (_has_message) {
|
if (_has_message) {
|
||||||
int rc = msg_->move (_message);
|
const int rc = msg_->move (_message);
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
_has_message = false;
|
_has_message = false;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
do {
|
||||||
// Get a message using fair queueing algorithm.
|
// Get a message using fair queueing algorithm.
|
||||||
int rc = _fq.recv (msg_);
|
const int rc = _fq.recv (msg_);
|
||||||
|
|
||||||
// If there's no message available, return immediately.
|
// If there's no message available, return immediately.
|
||||||
// The same when error occurs.
|
// The same when error occurs.
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// Filtering non matching messages
|
// Skip non matching messages
|
||||||
subscriptions_t::iterator it =
|
} while (0 == _subscriptions.count (std::string (msg_->group ())));
|
||||||
_subscriptions.find (std::string (msg_->group ()));
|
|
||||||
if (it != _subscriptions.end ())
|
// Found a matching message
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool zmq::dish_t::xhas_in ()
|
bool zmq::dish_t::xhas_in ()
|
||||||
|
|||||||
Reference in New Issue
Block a user