Refactor code so that messages go through engines

This commit is contained in:
Martin Hurton
2013-03-18 02:00:00 +01:00
parent c396144216
commit 7942db7606
30 changed files with 528 additions and 771 deletions

View File

@@ -24,7 +24,6 @@
#include "fd.hpp"
#include "i_engine.hpp"
#include "i_msg_sink.hpp"
#include "io_object.hpp"
#include "i_encoder.hpp"
#include "i_decoder.hpp"
@@ -43,12 +42,13 @@ namespace zmq
};
class io_thread_t;
class msg_t;
class session_base_t;
// This engine handles any socket with SOCK_STREAM semantics,
// e.g. TCP socket or an UNIX domain socket.
class stream_engine_t : public io_object_t, public i_engine, public i_msg_sink
class stream_engine_t : public io_object_t, public i_engine
{
public:
@@ -62,9 +62,6 @@ namespace zmq
void activate_in ();
void activate_out ();
// i_msg_sink interface implementation.
virtual int push_msg (msg_t *msg_);
// i_poll_events interface implementation.
void in_event ();
void out_event ();
@@ -94,11 +91,14 @@ namespace zmq
// peer -1 is returned.
int read (void *data_, size_t size_);
int read_msg (msg_t *msg_);
int write_msg (msg_t *msg_);
// Underlying socket.
fd_t s;
// True iff we are registered with an I/O poller.
bool io_enabled;
msg_t tx_msg;
handle_t handle;
@@ -137,6 +137,29 @@ namespace zmq
bool plugged;
bool terminating;
bool io_error;
// True iff the session could not accept more
// messages due to flow control.
bool congested;
// True iff the engine has received identity message.
bool identity_received;
// True iff the engine has sent identity message.
bool identity_sent;
// True iff the engine has received all ZMTP control messages.
bool rx_initialized;
// True iff the engine has sent all ZMTP control messages.
bool tx_initialized;
// Indicates whether the engine is to inject a phony
// subscription message into the incomming stream.
// Needed to support old peers.
bool subscription_required;
// Socket
zmq::socket_base_t *socket;