From e0246e32d79d71f8e73207b43aed8b23648e4fc7 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Thu, 21 Apr 2011 22:27:48 +0200 Subject: 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 --- src/pipe.hpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/pipe.hpp') 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 pipe_t; + typedef ypipe_t 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 (); -- cgit v1.2.3