mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-21 02:00:36 +01:00
Reduced code duplication between xread and xhas_in
This commit is contained in:
parent
3cca90ea44
commit
ad3d1e7762
23
src/dish.cpp
23
src/dish.cpp
@ -184,6 +184,11 @@ int zmq::dish_t::xrecv (msg_t *msg_)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return xxrecv (msg_);
|
||||||
|
}
|
||||||
|
|
||||||
|
int zmq::dish_t::xxrecv (msg_t *msg_)
|
||||||
|
{
|
||||||
do {
|
do {
|
||||||
// Get a message using fair queueing algorithm.
|
// Get a message using fair queueing algorithm.
|
||||||
const int rc = _fq.recv (msg_);
|
const int rc = _fq.recv (msg_);
|
||||||
@ -207,19 +212,11 @@ bool zmq::dish_t::xhas_in ()
|
|||||||
if (_has_message)
|
if (_has_message)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
do {
|
const int rc = xxrecv (&_message);
|
||||||
// Get a message using fair queueing algorithm.
|
if (rc != 0) {
|
||||||
const int rc = _fq.recv (&_message);
|
errno_assert (errno == EAGAIN);
|
||||||
|
return false;
|
||||||
// If there's no message available, return immediately.
|
}
|
||||||
// The same when error occurs.
|
|
||||||
if (rc != 0) {
|
|
||||||
errno_assert (errno == EAGAIN);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter out non matching messages
|
|
||||||
} while (0 == _subscriptions.count (std::string (_message.group ())));
|
|
||||||
|
|
||||||
// Matching message found
|
// Matching message found
|
||||||
_has_message = true;
|
_has_message = true;
|
||||||
|
@ -68,6 +68,8 @@ class dish_t : public socket_base_t
|
|||||||
int xleave (const char *group_);
|
int xleave (const char *group_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int xxrecv (zmq::msg_t *msg_);
|
||||||
|
|
||||||
// Send subscriptions to a pipe
|
// Send subscriptions to a pipe
|
||||||
void send_subscriptions (pipe_t *pipe_);
|
void send_subscriptions (pipe_t *pipe_);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user