Make it explicit that the probe function doesn't modify passed message

This commit is contained in:
Martin Hurton
2014-01-08 07:49:02 +01:00
parent 629221889d
commit d72ceb93be
8 changed files with 8 additions and 8 deletions

View File

@@ -111,7 +111,7 @@ namespace zmq
return has_msg; return has_msg;
} }
inline bool probe (bool (*fn)(msg_t &)) inline bool probe (bool (*fn)(const msg_t &))
{ {
scoped_lock_t lock (sync); scoped_lock_t lock (sync);
return (*fn) (*front); return (*fn) (*front);

View File

@@ -267,7 +267,7 @@ bool zmq::msg_t::is_identity () const
return (u.base.flags & identity) == identity; return (u.base.flags & identity) == identity;
} }
bool zmq::msg_t::is_delimiter () bool zmq::msg_t::is_delimiter () const
{ {
return u.base.type == type_delimiter; return u.base.type == type_delimiter;
} }

View File

@@ -70,7 +70,7 @@ namespace zmq
int64_t fd (); int64_t fd ();
void set_fd (int64_t fd_); void set_fd (int64_t fd_);
bool is_identity () const; bool is_identity () const;
bool is_delimiter (); bool is_delimiter () const;
bool is_vsm (); bool is_vsm ();
bool is_cmsg (); bool is_cmsg ();

View File

@@ -406,7 +406,7 @@ void zmq::pipe_t::terminate (bool delay_)
} }
} }
bool zmq::pipe_t::is_delimiter (msg_t &msg_) bool zmq::pipe_t::is_delimiter (const msg_t &msg_)
{ {
return msg_.is_delimiter (); return msg_.is_delimiter ();
} }

View File

@@ -199,7 +199,7 @@ namespace zmq
blob_t identity; blob_t identity;
// Returns true if the message is delimiter; false otherwise. // Returns true if the message is delimiter; false otherwise.
static bool is_delimiter (msg_t &msg_); static bool is_delimiter (const msg_t &msg_);
// Computes appropriate low watermark from the given high watermark. // Computes appropriate low watermark from the given high watermark.
static int compute_lwm (int hwm_); static int compute_lwm (int hwm_);

View File

@@ -166,7 +166,7 @@ namespace zmq
// Applies the function fn to the first elemenent in the pipe // Applies the function fn to the first elemenent in the pipe
// and returns the value returned by the fn. // and returns the value returned by the fn.
// The pipe mustn't be empty or the function crashes. // The pipe mustn't be empty or the function crashes.
inline bool probe (bool (*fn)(T &)) inline bool probe (bool (*fn)(const T &))
{ {
bool rc = check_read (); bool rc = check_read ();
zmq_assert (rc); zmq_assert (rc);

View File

@@ -37,7 +37,7 @@ namespace zmq
virtual bool flush () = 0; virtual bool flush () = 0;
virtual bool check_read () = 0; virtual bool check_read () = 0;
virtual bool read (T *value_) = 0; virtual bool read (T *value_) = 0;
virtual bool probe (bool (*fn)(T &)) = 0; virtual bool probe (bool (*fn)(const T &)) = 0;
}; };
} }

View File

@@ -107,7 +107,7 @@ namespace zmq
// Applies the function fn to the first elemenent in the pipe // Applies the function fn to the first elemenent in the pipe
// and returns the value returned by the fn. // and returns the value returned by the fn.
// The pipe mustn't be empty or the function crashes. // The pipe mustn't be empty or the function crashes.
inline bool probe (bool (*fn)(T &)) inline bool probe (bool (*fn)(const T &))
{ {
return dbuffer.probe (fn); return dbuffer.probe (fn);
} }