Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
f2ff2c6e
Commit
f2ff2c6e
authored
Sep 30, 2009
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checking for available messages added to ypipe/pipe
parent
84d854a0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
8 deletions
+30
-8
pipe.cpp
src/pipe.cpp
+11
-0
pipe.hpp
src/pipe.hpp
+3
-0
ypipe.hpp
src/ypipe.hpp
+16
-8
No files found.
src/pipe.cpp
View file @
f2ff2c6e
...
...
@@ -36,6 +36,17 @@ zmq::reader_t::~reader_t ()
{
}
bool
zmq
::
reader_t
::
check_read
()
{
// Check if there's an item in the pipe.
if
(
pipe
->
check_read
())
return
true
;
// If not, deactivate the pipe.
endpoint
->
kill
(
this
);
return
false
;
}
bool
zmq
::
reader_t
::
read
(
zmq_msg_t
*
msg_
)
{
if
(
!
pipe
->
read
(
msg_
))
{
...
...
src/pipe.hpp
View file @
f2ff2c6e
...
...
@@ -42,6 +42,9 @@ namespace zmq
void
set_endpoint
(
i_endpoint
*
endpoint_
);
// Returns true if there is at least one message to read in the pipe.
bool
check_read
();
// Reads a message to the underlying pipe.
bool
read
(
zmq_msg_t
*
msg_
);
...
...
src/ypipe.hpp
View file @
f2ff2c6e
...
...
@@ -106,16 +106,12 @@ namespace zmq
return
true
;
}
// Reads an item from the pipe. Returns false if there is no value.
// available.
inline
bool
read
(
T
*
value_
)
// Check whether item is available for reading.
inline
bool
check_read
()
{
// Was the value prefetched already? If so, return it.
if
(
&
queue
.
front
()
!=
r
)
{
*
value_
=
queue
.
front
();
queue
.
pop
();
// Was the value prefetched already? If so, return.
if
(
&
queue
.
front
()
!=
r
)
return
true
;
}
// There's no prefetched value, so let us prefetch more values.
// (Note that D is a template parameter. Becaue of that one of
...
...
@@ -165,6 +161,18 @@ namespace zmq
return
false
;
}
// There was at least one value prefetched.
return
true
;
}
// Reads an item from the pipe. Returns false if there is no value.
// available.
inline
bool
read
(
T
*
value_
)
{
// Try to prefetch a value.
if
(
!
check_read
())
return
false
;
// There was at least one value prefetched.
// Return it to the caller.
*
value_
=
queue
.
front
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment