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/xsub.hpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/xsub.hpp') diff --git a/src/xsub.hpp b/src/xsub.hpp index 6bd55ad..202a29f 100644 --- a/src/xsub.hpp +++ b/src/xsub.hpp @@ -21,10 +21,9 @@ #ifndef __ZMQ_XSUB_HPP_INCLUDED__ #define __ZMQ_XSUB_HPP_INCLUDED__ -#include "../include/zmq.h" - #include "trie.hpp" #include "socket_base.hpp" +#include "msg.hpp" #include "fq.hpp" namespace zmq @@ -42,9 +41,9 @@ namespace zmq // Overloads of functions from socket_base_t. void xattach_pipes (class reader_t *inpipe_, class writer_t *outpipe_, const blob_t &peer_identity_); - int xsend (zmq_msg_t *msg_, int options_); + int xsend (class msg_t *msg_, int options_); bool xhas_out (); - int xrecv (zmq_msg_t *msg_, int flags_); + int xrecv (class msg_t *msg_, int flags_); bool xhas_in (); private: @@ -53,7 +52,7 @@ namespace zmq void process_term (int linger_); // Check whether the message matches at least one subscription. - bool match (zmq_msg_t *msg_); + bool match (class msg_t *msg_); // Fair queueing object for inbound pipes. fq_t fq; @@ -64,7 +63,7 @@ namespace zmq // If true, 'message' contains a matching message to return on the // next recv call. bool has_message; - zmq_msg_t message; + msg_t message; // If true, part of a multipart message was already received, but // there are following parts still waiting. -- cgit v1.2.3