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
9f495942
Commit
9f495942
authored
Dec 05, 2009
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
C & C++ header files clean-up
parent
356ce8fe
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
41 deletions
+33
-41
zmq.h
bindings/c/zmq.h
+0
-0
zmq.hpp
bindings/cpp/zmq.hpp
+28
-34
ypipe.hpp
src/ypipe.hpp
+5
-7
No files found.
bindings/c/zmq.h
View file @
9f495942
This diff is collapsed.
Click to expand it.
bindings/cpp/zmq.hpp
View file @
9f495942
...
...
@@ -31,8 +31,13 @@ namespace zmq
{
typedef
zmq_free_fn
free_fn
;
typedef
zmq_pollitem_t
pollitem_t
;
inline
int
poll
(
zmq_pollitem_t
*
items_
,
int
nitems_
)
{
return
zmq_poll
(
items_
,
nitems_
);
}
// The class masquerades POSIX-style errno error as a C++ exception.
class
error_t
:
public
std
::
exception
{
public
:
...
...
@@ -49,37 +54,33 @@ namespace zmq
int
errnum
;
};
// A message. Caution: Don't change the body of the message once you've
// copied it - the behaviour is undefined. Don't change the body of the
// received message either - other threads may be accessing it in parallel.
class
message_t
:
private
zmq_msg_t
{
friend
class
socket_t
;
public
:
// Creates message size_ bytes long.
inline
message_t
(
size_t
size_
=
0
)
inline
message_t
()
{
int
rc
=
zmq_msg_init
(
this
);
if
(
rc
!=
0
)
throw
error_t
();
}
inline
message_t
(
size_t
size_
)
{
int
rc
=
zmq_msg_init_size
(
this
,
size_
);
if
(
rc
!=
0
)
throw
error_t
();
}
// Creates message from the supplied buffer. 0MQ takes care of
// deallocating the buffer once it is not needed. The deallocation
// function is supplied in ffn_ parameter. If ffn_ is NULL, no
// deallocation happens - this is useful for sending static buffers.
inline
message_t
(
void
*
data_
,
size_t
size_
,
free_fn
*
ffn_
)
inline
message_t
(
void
*
data_
,
size_t
size_
,
free_fn
*
ffn_
)
{
int
rc
=
zmq_msg_init_data
(
this
,
data_
,
size_
,
ffn_
);
if
(
rc
!=
0
)
throw
error_t
();
}
// Destroys the message.
inline
~
message_t
()
{
int
rc
=
zmq_msg_close
(
this
);
...
...
@@ -87,9 +88,16 @@ namespace zmq
throw
error_t
();
}
// Destroys old content of the message and allocates buffer for the
// new message body. Having this as a separate function allows user
// to reuse once-allocated message for multiple times.
inline
void
rebuild
()
{
int
rc
=
zmq_msg_close
(
this
);
if
(
rc
!=
0
)
throw
error_t
();
rc
=
zmq_msg_init
(
this
);
if
(
rc
!=
0
)
throw
error_t
();
}
inline
void
rebuild
(
size_t
size_
)
{
int
rc
=
zmq_msg_close
(
this
);
...
...
@@ -100,9 +108,6 @@ namespace zmq
throw
error_t
();
}
// Same as above, however, the message is rebuilt from the supplied
// buffer. See appropriate constructor for discussion of buffer
// deallocation mechanism.
inline
void
rebuild
(
void
*
data_
,
size_t
size_
,
free_fn
*
ffn_
)
{
int
rc
=
zmq_msg_close
(
this
);
...
...
@@ -113,34 +118,25 @@ namespace zmq
throw
error_t
();
}
// Moves the message content from one message to the another. If the
// destination message have contained data prior to the operation
// these get deallocated. The source message will contain 0 bytes
// of data after the operation.
inline
void
move_to
(
message_t
*
msg_
)
inline
void
move
(
message_t
*
msg_
)
{
int
rc
=
zmq_msg_move
(
this
,
(
zmq_msg_t
*
)
msg_
);
if
(
rc
!=
0
)
throw
error_t
();
}
// Copies the message content from one message to the another. If the
// destination message have contained data prior to the operation
// these get deallocated.
inline
void
copy_to
(
message_t
*
msg_
)
inline
void
copy
(
message_t
*
msg_
)
{
int
rc
=
zmq_msg_copy
(
this
,
(
zmq_msg_t
*
)
msg_
);
if
(
rc
!=
0
)
throw
error_t
();
}
// Returns pointer to message's data buffer.
inline
void
*
data
()
{
return
zmq_msg_data
(
this
);
}
// Returns the size of message data buffer.
inline
size_t
size
()
{
return
zmq_msg_size
(
this
);
...
...
@@ -177,7 +173,6 @@ namespace zmq
void
*
ptr
;
// Disable copying.
context_t
(
const
context_t
&
);
void
operator
=
(
const
context_t
&
);
};
...
...
@@ -186,7 +181,7 @@ namespace zmq
{
public
:
inline
socket_t
(
context_t
&
context_
,
int
type_
=
0
)
inline
socket_t
(
context_t
&
context_
,
int
type_
)
{
ptr
=
zmq_socket
(
context_
.
ptr
,
type_
);
if
(
ptr
==
NULL
)
...
...
@@ -258,7 +253,6 @@ namespace zmq
void
*
ptr
;
// Disable copying.
socket_t
(
const
socket_t
&
);
void
operator
=
(
const
socket_t
&
);
};
...
...
src/ypipe.hpp
View file @
9f495942
...
...
@@ -137,14 +137,12 @@ namespace zmq
stop
=
false
;
return
false
;
}
else
{
// We want to do only a single prefetch in D scenario
// before going asleep. Thus, we set stop variable to true
// so that we can return false next time the prefetch is
// attempted.
stop
=
true
;
}
// We want to do only a single prefetch in D scenario
// before going asleep. Thus, we set stop variable to true
// so that we can return false next time the prefetch is
// attempted.
stop
=
true
;
}
else
{
...
...
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