Commit b3bac176 authored by Martin Sustrik's avatar Martin Sustrik

tcp_engine renamed to stream engine

The engine was not used exclusively for TCP connections.
Rather it was used to handle any socket with SOCK_STREAM
semantics. The class was renamed to reflect its true function.
Signed-off-by: 's avatarMartin Sustrik <sustrik@250bpm.com>
parent 41457e1f
...@@ -60,9 +60,9 @@ libzmq_la_SOURCES = \ ...@@ -60,9 +60,9 @@ libzmq_la_SOURCES = \
signaler.hpp \ signaler.hpp \
socket_base.hpp \ socket_base.hpp \
stdint.hpp \ stdint.hpp \
stream_engine.hpp \
sub.hpp \ sub.hpp \
tcp_connecter.hpp \ tcp_connecter.hpp \
tcp_engine.hpp \
tcp_listener.hpp \ tcp_listener.hpp \
thread.hpp \ thread.hpp \
trie.hpp \ trie.hpp \
...@@ -117,9 +117,9 @@ libzmq_la_SOURCES = \ ...@@ -117,9 +117,9 @@ libzmq_la_SOURCES = \
session.cpp \ session.cpp \
signaler.cpp \ signaler.cpp \
socket_base.cpp \ socket_base.cpp \
stream_engine.cpp \
sub.cpp \ sub.cpp \
tcp_connecter.cpp \ tcp_connecter.cpp \
tcp_engine.cpp \
tcp_listener.cpp \ tcp_listener.cpp \
thread.cpp \ thread.cpp \
trie.cpp \ trie.cpp \
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <new> #include <new>
#include <string> #include <string>
#include "tcp_engine.hpp" #include "stream_engine.hpp"
#include "io_thread.hpp" #include "io_thread.hpp"
#include "platform.hpp" #include "platform.hpp"
#include "random.hpp" #include "random.hpp"
...@@ -99,7 +99,7 @@ void zmq::ipc_connecter_t::out_event () ...@@ -99,7 +99,7 @@ void zmq::ipc_connecter_t::out_event ()
} }
// Create the engine object for this connection. // Create the engine object for this connection.
tcp_engine_t *engine = new (std::nothrow) tcp_engine_t (fd, options); stream_engine_t *engine = new (std::nothrow) stream_engine_t (fd, options);
alloc_assert (engine); alloc_assert (engine);
// Attach the engine to the corresponding session object. // Attach the engine to the corresponding session object.
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <string.h> #include <string.h>
#include "tcp_engine.hpp" #include "stream_engine.hpp"
#include "io_thread.hpp" #include "io_thread.hpp"
#include "session.hpp" #include "session.hpp"
#include "config.hpp" #include "config.hpp"
...@@ -78,7 +78,7 @@ void zmq::ipc_listener_t::in_event () ...@@ -78,7 +78,7 @@ void zmq::ipc_listener_t::in_event ()
return; return;
// Create the engine object for this connection. // Create the engine object for this connection.
tcp_engine_t *engine = new (std::nothrow) tcp_engine_t (fd, options); stream_engine_t *engine = new (std::nothrow) stream_engine_t (fd, options);
alloc_assert (engine); alloc_assert (engine);
// Choose I/O thread to run connecter in. Given that we are already // Choose I/O thread to run connecter in. Given that we are already
......
...@@ -34,14 +34,14 @@ ...@@ -34,14 +34,14 @@
#include <string.h> #include <string.h>
#include <new> #include <new>
#include "tcp_engine.hpp" #include "stream_engine.hpp"
#include "io_thread.hpp" #include "io_thread.hpp"
#include "session.hpp" #include "session.hpp"
#include "config.hpp" #include "config.hpp"
#include "err.hpp" #include "err.hpp"
#include "ip.hpp" #include "ip.hpp"
zmq::tcp_engine_t::tcp_engine_t (fd_t fd_, const options_t &options_) : zmq::stream_engine_t::stream_engine_t (fd_t fd_, const options_t &options_) :
s (fd_), s (fd_),
inpos (NULL), inpos (NULL),
insize (0), insize (0),
...@@ -86,7 +86,7 @@ zmq::tcp_engine_t::tcp_engine_t (fd_t fd_, const options_t &options_) : ...@@ -86,7 +86,7 @@ zmq::tcp_engine_t::tcp_engine_t (fd_t fd_, const options_t &options_) :
#endif #endif
} }
zmq::tcp_engine_t::~tcp_engine_t () zmq::stream_engine_t::~stream_engine_t ()
{ {
zmq_assert (!plugged); zmq_assert (!plugged);
...@@ -102,7 +102,7 @@ zmq::tcp_engine_t::~tcp_engine_t () ...@@ -102,7 +102,7 @@ zmq::tcp_engine_t::~tcp_engine_t ()
} }
} }
void zmq::tcp_engine_t::plug (io_thread_t *io_thread_, session_t *session_) void zmq::stream_engine_t::plug (io_thread_t *io_thread_, session_t *session_)
{ {
zmq_assert (!plugged); zmq_assert (!plugged);
plugged = true; plugged = true;
...@@ -125,7 +125,7 @@ void zmq::tcp_engine_t::plug (io_thread_t *io_thread_, session_t *session_) ...@@ -125,7 +125,7 @@ void zmq::tcp_engine_t::plug (io_thread_t *io_thread_, session_t *session_)
in_event (); in_event ();
} }
void zmq::tcp_engine_t::unplug () void zmq::stream_engine_t::unplug ()
{ {
zmq_assert (plugged); zmq_assert (plugged);
plugged = false; plugged = false;
...@@ -143,13 +143,13 @@ void zmq::tcp_engine_t::unplug () ...@@ -143,13 +143,13 @@ void zmq::tcp_engine_t::unplug ()
session = NULL; session = NULL;
} }
void zmq::tcp_engine_t::terminate () void zmq::stream_engine_t::terminate ()
{ {
unplug (); unplug ();
delete this; delete this;
} }
void zmq::tcp_engine_t::in_event () void zmq::stream_engine_t::in_event ()
{ {
bool disconnection = false; bool disconnection = false;
...@@ -204,7 +204,7 @@ void zmq::tcp_engine_t::in_event () ...@@ -204,7 +204,7 @@ void zmq::tcp_engine_t::in_event ()
error (); error ();
} }
void zmq::tcp_engine_t::out_event () void zmq::stream_engine_t::out_event ()
{ {
// If write buffer is empty, try to read new data from the encoder. // If write buffer is empty, try to read new data from the encoder.
if (!outsize) { if (!outsize) {
...@@ -243,7 +243,7 @@ void zmq::tcp_engine_t::out_event () ...@@ -243,7 +243,7 @@ void zmq::tcp_engine_t::out_event ()
outsize -= nbytes; outsize -= nbytes;
} }
void zmq::tcp_engine_t::activate_out () void zmq::stream_engine_t::activate_out ()
{ {
set_pollout (handle); set_pollout (handle);
...@@ -254,7 +254,7 @@ void zmq::tcp_engine_t::activate_out () ...@@ -254,7 +254,7 @@ void zmq::tcp_engine_t::activate_out ()
out_event (); out_event ();
} }
void zmq::tcp_engine_t::activate_in () void zmq::stream_engine_t::activate_in ()
{ {
set_pollin (handle); set_pollin (handle);
...@@ -262,7 +262,7 @@ void zmq::tcp_engine_t::activate_in () ...@@ -262,7 +262,7 @@ void zmq::tcp_engine_t::activate_in ()
in_event (); in_event ();
} }
void zmq::tcp_engine_t::error () void zmq::stream_engine_t::error ()
{ {
zmq_assert (session); zmq_assert (session);
session->detach (); session->detach ();
...@@ -270,7 +270,7 @@ void zmq::tcp_engine_t::error () ...@@ -270,7 +270,7 @@ void zmq::tcp_engine_t::error ()
delete this; delete this;
} }
int zmq::tcp_engine_t::write (const void *data_, size_t size_) int zmq::stream_engine_t::write (const void *data_, size_t size_)
{ {
#ifdef ZMQ_HAVE_WINDOWS #ifdef ZMQ_HAVE_WINDOWS
...@@ -315,7 +315,7 @@ int zmq::tcp_engine_t::write (const void *data_, size_t size_) ...@@ -315,7 +315,7 @@ int zmq::tcp_engine_t::write (const void *data_, size_t size_)
#endif #endif
} }
int zmq::tcp_engine_t::read (void *data_, size_t size_) int zmq::stream_engine_t::read (void *data_, size_t size_)
{ {
#ifdef ZMQ_HAVE_WINDOWS #ifdef ZMQ_HAVE_WINDOWS
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __ZMQ_TCP_ENGINE_HPP_INCLUDED__ #ifndef __ZMQ_STREAM_ENGINE_HPP_INCLUDED__
#define __ZMQ_TCP_ENGINE_HPP_INCLUDED__ #define __ZMQ_STREAM_ENGINE_HPP_INCLUDED__
#include <stddef.h> #include <stddef.h>
...@@ -33,12 +33,15 @@ ...@@ -33,12 +33,15 @@
namespace zmq namespace zmq
{ {
class tcp_engine_t : public io_object_t, public i_engine // 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: public:
tcp_engine_t (fd_t fd_, const options_t &options_); stream_engine_t (fd_t fd_, const options_t &options_);
~tcp_engine_t (); ~stream_engine_t ();
// i_engine interface implementation. // i_engine interface implementation.
void plug (class io_thread_t *io_thread_, class session_t *session_); void plug (class io_thread_t *io_thread_, class session_t *session_);
...@@ -90,8 +93,8 @@ namespace zmq ...@@ -90,8 +93,8 @@ namespace zmq
bool plugged; bool plugged;
tcp_engine_t (const tcp_engine_t&); stream_engine_t (const stream_engine_t&);
const tcp_engine_t &operator = (const tcp_engine_t&); const stream_engine_t &operator = (const stream_engine_t&);
}; };
} }
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <string> #include <string>
#include "tcp_connecter.hpp" #include "tcp_connecter.hpp"
#include "tcp_engine.hpp" #include "stream_engine.hpp"
#include "io_thread.hpp" #include "io_thread.hpp"
#include "platform.hpp" #include "platform.hpp"
#include "random.hpp" #include "random.hpp"
...@@ -109,7 +109,7 @@ void zmq::tcp_connecter_t::out_event () ...@@ -109,7 +109,7 @@ void zmq::tcp_connecter_t::out_event ()
tune_tcp_socket (fd); tune_tcp_socket (fd);
// Create the engine object for this connection. // Create the engine object for this connection.
tcp_engine_t *engine = new (std::nothrow) tcp_engine_t (fd, options); stream_engine_t *engine = new (std::nothrow) stream_engine_t (fd, options);
alloc_assert (engine); alloc_assert (engine);
// Attach the engine to the corresponding session object. // Attach the engine to the corresponding session object.
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "platform.hpp" #include "platform.hpp"
#include "tcp_listener.hpp" #include "tcp_listener.hpp"
#include "tcp_engine.hpp" #include "stream_engine.hpp"
#include "io_thread.hpp" #include "io_thread.hpp"
#include "session.hpp" #include "session.hpp"
#include "config.hpp" #include "config.hpp"
...@@ -90,7 +90,7 @@ void zmq::tcp_listener_t::in_event () ...@@ -90,7 +90,7 @@ void zmq::tcp_listener_t::in_event ()
tune_tcp_socket (fd); tune_tcp_socket (fd);
// Create the engine object for this connection. // Create the engine object for this connection.
tcp_engine_t *engine = new (std::nothrow) tcp_engine_t (fd, options); stream_engine_t *engine = new (std::nothrow) stream_engine_t (fd, options);
alloc_assert (engine); alloc_assert (engine);
// Choose I/O thread to run connecter in. Given that we are already // Choose I/O thread to run connecter in. Given that we are already
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <new> #include <new>
#include <string> #include <string>
#include "tcp_engine.hpp" #include "stream_engine.hpp"
#include "io_thread.hpp" #include "io_thread.hpp"
#include "platform.hpp" #include "platform.hpp"
#include "random.hpp" #include "random.hpp"
...@@ -141,7 +141,7 @@ void zmq::vtcp_connecter_t::out_event () ...@@ -141,7 +141,7 @@ void zmq::vtcp_connecter_t::out_event ()
} }
// Create the engine object for this connection. // Create the engine object for this connection.
tcp_engine_t *engine = new (std::nothrow) tcp_engine_t (fd, options); stream_engine_t *engine = new (std::nothrow) stream_engine_t (fd, options);
alloc_assert (engine); alloc_assert (engine);
// Attach the engine to the corresponding session object. // Attach the engine to the corresponding session object.
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <string.h> #include <string.h>
#include <vtcp.h> #include <vtcp.h>
#include "tcp_engine.hpp" #include "stream_engine.hpp"
#include "session.hpp" #include "session.hpp"
#include "stdint.hpp" #include "stdint.hpp"
#include "err.hpp" #include "err.hpp"
...@@ -104,7 +104,7 @@ void zmq::vtcp_listener_t::in_event () ...@@ -104,7 +104,7 @@ void zmq::vtcp_listener_t::in_event ()
tune_tcp_socket (fd); tune_tcp_socket (fd);
// Create the engine object for this connection. // Create the engine object for this connection.
tcp_engine_t *engine = new (std::nothrow) tcp_engine_t (fd, options); stream_engine_t *engine = new (std::nothrow) stream_engine_t (fd, options);
alloc_assert (engine); alloc_assert (engine);
// Choose I/O thread to run connecter in. Given that we are already // Choose I/O thread to run connecter in. Given that we are already
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment