From 61ee6fae536a8000be87b5aaf271f6519a3b7d3f Mon Sep 17 00:00:00 2001 From: Martin Hurton Date: Mon, 1 Mar 2010 10:13:26 +0100 Subject: Implement flow control This commit introduces the necessary changes necessary for implementing flow control. None of the socket types implements the flow control yet. The code will crash when the flow control is enabled and the thw lwm is reached. The following commits will add flow-control support for individual socket types. --- src/zmq_engine.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/zmq_engine.cpp') diff --git a/src/zmq_engine.cpp b/src/zmq_engine.cpp index 623ca63..8e0392c 100644 --- a/src/zmq_engine.cpp +++ b/src/zmq_engine.cpp @@ -102,19 +102,19 @@ void zmq::zmq_engine_t::in_event () // Push the data to the decoder. size_t processed = decoder.process_buffer (inpos, insize); - // Adjust the buffer. - inpos += processed; - insize -= processed; - // Stop polling for input if we got stuck. if (processed < insize) { - // This may happen if queue limits are implemented or when + // This may happen if queue limits are in effect or when // init object reads all required information from the socket // and rejects to read more data. reset_pollin (handle); } + // Adjust the buffer. + inpos += processed; + insize -= processed; + // Flush all messages the decoder may have produced. inout->flush (); @@ -162,6 +162,13 @@ void zmq::zmq_engine_t::revive () out_event (); } +void zmq::zmq_engine_t::resume_input () +{ + set_pollin (handle); + + in_event (); +} + void zmq::zmq_engine_t::add_prefix (const blob_t &identity_) { decoder.add_prefix (identity_); -- cgit v1.2.3