From 10533a560b4af1d3dae63c87c737e25bbdb78998 Mon Sep 17 00:00:00 2001 From: Martin Hurton Date: Wed, 14 Jul 2010 18:31:17 +0200 Subject: pipe: check_read() should check for message delimiter --- src/ypipe.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/ypipe.hpp') diff --git a/src/ypipe.hpp b/src/ypipe.hpp index 2a2d725..26f021c 100644 --- a/src/ypipe.hpp +++ b/src/ypipe.hpp @@ -162,6 +162,17 @@ namespace zmq return true; } + // Applies the function fn to the first elemenent in the pipe + // and returns the value returned by the fn. + // The pipe mustn't be empty or the function crashes. + inline bool probe (bool (*fn)(T &)) + { + bool rc = check_read (); + zmq_assert (rc); + + return (*fn) (queue.front ()); + } + protected: // Allocation-efficient queue to store pipe items. -- cgit v1.2.3