summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-08-16 12:44:34 +0200
committerMartin Sustrik <sustrik@250bpm.com>2011-08-16 12:44:34 +0200
commitb3bac1760735703a11297df3d0e2a2e5252aa45e (patch)
tree79da97483bc62d67f8cdf008af2b120b54b77324 /src
parent41457e1ff12dffb62e2dc98cec0be2c5deb79207 (diff)
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: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/ipc_connecter.cpp4
-rw-r--r--src/ipc_listener.cpp4
-rw-r--r--src/stream_engine.cpp (renamed from src/tcp_engine.cpp)26
-rw-r--r--src/stream_engine.hpp (renamed from src/tcp_engine.hpp)17
-rw-r--r--src/tcp_connecter.cpp4
-rw-r--r--src/tcp_listener.cpp4
-rw-r--r--src/vtcp_connecter.cpp4
-rw-r--r--src/vtcp_listener.cpp4
9 files changed, 37 insertions, 34 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 9f5ea65..93c51ed 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -60,9 +60,9 @@ libzmq_la_SOURCES = \
signaler.hpp \
socket_base.hpp \
stdint.hpp \
+ stream_engine.hpp \
sub.hpp \
tcp_connecter.hpp \
- tcp_engine.hpp \
tcp_listener.hpp \
thread.hpp \
trie.hpp \
@@ -117,9 +117,9 @@ libzmq_la_SOURCES = \
session.cpp \
signaler.cpp \
socket_base.cpp \
+ stream_engine.cpp \
sub.cpp \
tcp_connecter.cpp \
- tcp_engine.cpp \
tcp_listener.cpp \
thread.cpp \
trie.cpp \
diff --git a/src/ipc_connecter.cpp b/src/ipc_connecter.cpp
index 4b8f3bf..2862db4 100644
--- a/src/ipc_connecter.cpp
+++ b/src/ipc_connecter.cpp
@@ -25,7 +25,7 @@
#include <new>
#include <string>
-#include "tcp_engine.hpp"
+#include "stream_engine.hpp"
#include "io_thread.hpp"
#include "platform.hpp"
#include "random.hpp"
@@ -99,7 +99,7 @@ void zmq::ipc_connecter_t::out_event ()
}
// 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);
// Attach the engine to the corresponding session object.
diff --git a/src/ipc_listener.cpp b/src/ipc_listener.cpp
index 200a2bc..9e35af3 100644
--- a/src/ipc_listener.cpp
+++ b/src/ipc_listener.cpp
@@ -26,7 +26,7 @@
#include <string.h>
-#include "tcp_engine.hpp"
+#include "stream_engine.hpp"
#include "io_thread.hpp"
#include "session.hpp"
#include "config.hpp"
@@ -78,7 +78,7 @@ void zmq::ipc_listener_t::in_event ()
return;
// 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);
// Choose I/O thread to run connecter in. Given that we are already
diff --git a/src/tcp_engine.cpp b/src/stream_engine.cpp
index f938d71..15e7c21 100644
--- a/src/tcp_engine.cpp
+++ b/src/stream_engine.cpp
@@ -34,14 +34,14 @@
#include <string.h>
#include <new>
-#include "tcp_engine.hpp"
+#include "stream_engine.hpp"
#include "io_thread.hpp"
#include "session.hpp"
#include "config.hpp"
#include "err.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_),
inpos (NULL),
insize (0),
@@ -86,7 +86,7 @@ zmq::tcp_engine_t::tcp_engine_t (fd_t fd_, const options_t &options_) :
#endif
}
-zmq::tcp_engine_t::~tcp_engine_t ()
+zmq::stream_engine_t::~stream_engine_t ()
{
zmq_assert (!plugged);
@@ -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);
plugged = true;
@@ -125,7 +125,7 @@ void zmq::tcp_engine_t::plug (io_thread_t *io_thread_, session_t *session_)
in_event ();
}
-void zmq::tcp_engine_t::unplug ()
+void zmq::stream_engine_t::unplug ()
{
zmq_assert (plugged);
plugged = false;
@@ -143,13 +143,13 @@ void zmq::tcp_engine_t::unplug ()
session = NULL;
}
-void zmq::tcp_engine_t::terminate ()
+void zmq::stream_engine_t::terminate ()
{
unplug ();
delete this;
}
-void zmq::tcp_engine_t::in_event ()
+void zmq::stream_engine_t::in_event ()
{
bool disconnection = false;
@@ -204,7 +204,7 @@ void zmq::tcp_engine_t::in_event ()
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 (!outsize) {
@@ -243,7 +243,7 @@ void zmq::tcp_engine_t::out_event ()
outsize -= nbytes;
}
-void zmq::tcp_engine_t::activate_out ()
+void zmq::stream_engine_t::activate_out ()
{
set_pollout (handle);
@@ -254,7 +254,7 @@ void zmq::tcp_engine_t::activate_out ()
out_event ();
}
-void zmq::tcp_engine_t::activate_in ()
+void zmq::stream_engine_t::activate_in ()
{
set_pollin (handle);
@@ -262,7 +262,7 @@ void zmq::tcp_engine_t::activate_in ()
in_event ();
}
-void zmq::tcp_engine_t::error ()
+void zmq::stream_engine_t::error ()
{
zmq_assert (session);
session->detach ();
@@ -270,7 +270,7 @@ void zmq::tcp_engine_t::error ()
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
@@ -315,7 +315,7 @@ int zmq::tcp_engine_t::write (const void *data_, size_t size_)
#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
diff --git a/src/tcp_engine.hpp b/src/stream_engine.hpp
index 6a41883..ac9a5be 100644
--- a/src/tcp_engine.hpp
+++ b/src/stream_engine.hpp
@@ -18,8 +18,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef __ZMQ_TCP_ENGINE_HPP_INCLUDED__
-#define __ZMQ_TCP_ENGINE_HPP_INCLUDED__
+#ifndef __ZMQ_STREAM_ENGINE_HPP_INCLUDED__
+#define __ZMQ_STREAM_ENGINE_HPP_INCLUDED__
#include <stddef.h>
@@ -33,12 +33,15 @@
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:
- tcp_engine_t (fd_t fd_, const options_t &options_);
- ~tcp_engine_t ();
+ stream_engine_t (fd_t fd_, const options_t &options_);
+ ~stream_engine_t ();
// i_engine interface implementation.
void plug (class io_thread_t *io_thread_, class session_t *session_);
@@ -90,8 +93,8 @@ namespace zmq
bool plugged;
- tcp_engine_t (const tcp_engine_t&);
- const tcp_engine_t &operator = (const tcp_engine_t&);
+ stream_engine_t (const stream_engine_t&);
+ const stream_engine_t &operator = (const stream_engine_t&);
};
}
diff --git a/src/tcp_connecter.cpp b/src/tcp_connecter.cpp
index 7531445..10e1be6 100644
--- a/src/tcp_connecter.cpp
+++ b/src/tcp_connecter.cpp
@@ -22,7 +22,7 @@
#include <string>
#include "tcp_connecter.hpp"
-#include "tcp_engine.hpp"
+#include "stream_engine.hpp"
#include "io_thread.hpp"
#include "platform.hpp"
#include "random.hpp"
@@ -109,7 +109,7 @@ void zmq::tcp_connecter_t::out_event ()
tune_tcp_socket (fd);
// 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);
// Attach the engine to the corresponding session object.
diff --git a/src/tcp_listener.cpp b/src/tcp_listener.cpp
index 406b4d0..dd654b2 100644
--- a/src/tcp_listener.cpp
+++ b/src/tcp_listener.cpp
@@ -24,7 +24,7 @@
#include "platform.hpp"
#include "tcp_listener.hpp"
-#include "tcp_engine.hpp"
+#include "stream_engine.hpp"
#include "io_thread.hpp"
#include "session.hpp"
#include "config.hpp"
@@ -90,7 +90,7 @@ void zmq::tcp_listener_t::in_event ()
tune_tcp_socket (fd);
// 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);
// Choose I/O thread to run connecter in. Given that we are already
diff --git a/src/vtcp_connecter.cpp b/src/vtcp_connecter.cpp
index f281b23..61e7e84 100644
--- a/src/vtcp_connecter.cpp
+++ b/src/vtcp_connecter.cpp
@@ -25,7 +25,7 @@
#include <new>
#include <string>
-#include "tcp_engine.hpp"
+#include "stream_engine.hpp"
#include "io_thread.hpp"
#include "platform.hpp"
#include "random.hpp"
@@ -141,7 +141,7 @@ void zmq::vtcp_connecter_t::out_event ()
}
// 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);
// Attach the engine to the corresponding session object.
diff --git a/src/vtcp_listener.cpp b/src/vtcp_listener.cpp
index 9a897e4..b394833 100644
--- a/src/vtcp_listener.cpp
+++ b/src/vtcp_listener.cpp
@@ -26,7 +26,7 @@
#include <string.h>
#include <vtcp.h>
-#include "tcp_engine.hpp"
+#include "stream_engine.hpp"
#include "session.hpp"
#include "stdint.hpp"
#include "err.hpp"
@@ -104,7 +104,7 @@ void zmq::vtcp_listener_t::in_event ()
tune_tcp_socket (fd);
// 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);
// Choose I/O thread to run connecter in. Given that we are already