summaryrefslogtreecommitdiff
path: root/src/pipe.hpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-04-21 22:27:48 +0200
committerMartin Sustrik <sustrik@250bpm.com>2011-04-21 22:27:48 +0200
commite0246e32d79d71f8e73207b43aed8b23648e4fc7 (patch)
tree9952ee6fd39f4e27bbe932f6b6f30f0073009369 /src/pipe.hpp
parent581697695aac72894f2d3fefac904b9d50b3ba67 (diff)
Message-related functionality factored out into msg_t class.
This patch addresses serveral issues: 1. It gathers message related functionality scattered over whole codebase into a single class. 2. It makes zmq_msg_t an opaque datatype. Internals of the class don't pollute zmq.h header file. 3. zmq_msg_t size decreases from 48 to 32 bytes. That saves ~33% of memory in scenarios with large amount of small messages. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/pipe.hpp')
-rw-r--r--src/pipe.hpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/pipe.hpp b/src/pipe.hpp
index 3230d02..75b5c47 100644
--- a/src/pipe.hpp
+++ b/src/pipe.hpp
@@ -21,8 +21,7 @@
#ifndef __ZMQ_PIPE_HPP_INCLUDED__
#define __ZMQ_PIPE_HPP_INCLUDED__
-#include "../include/zmq.h"
-
+#include "msg.hpp"
#include "array.hpp"
#include "ypipe.hpp"
#include "config.hpp"
@@ -43,7 +42,7 @@ namespace zmq
// event. When endpoint processes the event and returns, associated
// reader/writer object is deallocated.
- typedef ypipe_t <zmq_msg_t, message_pipe_granularity> pipe_t;
+ typedef ypipe_t <msg_t, message_pipe_granularity> pipe_t;
struct i_reader_events
{
@@ -69,7 +68,7 @@ namespace zmq
bool check_read ();
// Reads a message to the underlying pipe.
- bool read (zmq_msg_t *msg_);
+ bool read (msg_t *msg_);
// Ask pipe to terminate.
void terminate ();
@@ -87,7 +86,7 @@ namespace zmq
void process_pipe_term_ack ();
// Returns true if the message is delimiter; false otherwise.
- static bool is_delimiter (zmq_msg_t &msg_);
+ static bool is_delimiter (msg_t &msg_);
// True, if pipe can be read from.
bool active;
@@ -136,11 +135,11 @@ namespace zmq
// Checks whether messages can be written to the pipe.
// If writing the message would cause high watermark
// the function returns false.
- bool check_write (zmq_msg_t *msg_);
+ bool check_write (msg_t *msg_);
// Writes a message to the underlying pipe. Returns false if the
// message cannot be written because high watermark was reached.
- bool write (zmq_msg_t *msg_);
+ bool write (msg_t *msg_);
// Remove unfinished part of a message from the pipe.
void rollback ();