Problem: Thread-safe solution for modify hwm of pipe

Solution: where change pipe hwm, send a command (new type pipe_hwm) to peer, so peer pipe can modify hwm thread-safely
This commit is contained in:
laplaceyang
2017-01-11 10:49:54 +08:00
parent 4fc313d152
commit 107f2441d5
6 changed files with 43 additions and 0 deletions

View File

@@ -118,6 +118,10 @@ void zmq::object_t::process_command (command_t &cmd_)
process_pipe_term_ack ();
break;
case command_t::pipe_hwm:
process_pipe_hwm (cmd_.args.pipe_hwm.inhwm, cmd_.args.pipe_hwm.outhwm);
break;
case command_t::term_req:
process_term_req (cmd_.args.term_req.object);
break;
@@ -291,6 +295,16 @@ void zmq::object_t::send_pipe_term_ack (pipe_t *destination_)
send_command (cmd);
}
void zmq::object_t::send_pipe_hwm (pipe_t *destination_, int inhwm_, int outhwm_)
{
command_t cmd;
cmd.destination = destination_;
cmd.type = command_t::pipe_hwm;
cmd.args.pipe_hwm.inhwm = inhwm_;
cmd.args.pipe_hwm.outhwm = outhwm_;
send_command (cmd);
}
void zmq::object_t::send_term_req (own_t *destination_,
own_t *object_)
{
@@ -401,6 +415,11 @@ void zmq::object_t::process_pipe_term_ack ()
zmq_assert (false);
}
void zmq::object_t::process_pipe_hwm (int, int)
{
zmq_assert (false);
}
void zmq::object_t::process_term_req (own_t *)
{
zmq_assert (false);