mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-16 20:41:18 +08:00
Removed code duplication in process_commands
This commit is contained in:
parent
da8024d3c9
commit
6357890ff6
@ -1317,12 +1317,7 @@ void zmq::socket_base_t::start_reaping (poller_t *poller_)
|
|||||||
|
|
||||||
int zmq::socket_base_t::process_commands (int timeout_, bool throttle_)
|
int zmq::socket_base_t::process_commands (int timeout_, bool throttle_)
|
||||||
{
|
{
|
||||||
int rc;
|
if (timeout_ == 0) {
|
||||||
command_t cmd;
|
|
||||||
if (timeout_ != 0) {
|
|
||||||
// If we are asked to wait, simply ask mailbox to wait.
|
|
||||||
rc = _mailbox->recv (&cmd, timeout_);
|
|
||||||
} else {
|
|
||||||
// If we are asked not to wait, check whether we haven't processed
|
// If we are asked not to wait, check whether we haven't processed
|
||||||
// commands recently, so that we can throttle the new commands.
|
// commands recently, so that we can throttle the new commands.
|
||||||
|
|
||||||
@ -1343,11 +1338,12 @@ int zmq::socket_base_t::process_commands (int timeout_, bool throttle_)
|
|||||||
return 0;
|
return 0;
|
||||||
_last_tsc = tsc;
|
_last_tsc = tsc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether there are any commands pending for this thread.
|
|
||||||
rc = _mailbox->recv (&cmd, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check whether there are any commands pending for this thread.
|
||||||
|
command_t cmd;
|
||||||
|
int rc = _mailbox->recv (&cmd, timeout_);
|
||||||
|
|
||||||
// Process all available commands.
|
// Process all available commands.
|
||||||
while (rc == 0) {
|
while (rc == 0) {
|
||||||
cmd.destination->process_command (cmd);
|
cmd.destination->process_command (cmd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user