diff options
author | Martin Hurton <hurtonm@gmail.com> | 2010-07-14 18:31:17 +0200 |
---|---|---|
committer | Martin Hurton <hurtonm@gmail.com> | 2010-07-24 17:33:54 +0200 |
commit | 10533a560b4af1d3dae63c87c737e25bbdb78998 (patch) | |
tree | f46481d018f32f4cdba9ff1397b2214bbc0acfec /src/ypipe.hpp | |
parent | e1c596b37eef2c2c72c605d7bf4a5c97050add6b (diff) |
pipe: check_read() should check for message delimiter
Diffstat (limited to 'src/ypipe.hpp')
-rw-r--r-- | src/ypipe.hpp | 11 |
1 files changed, 11 insertions, 0 deletions
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. |