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
507718ee
Commit
507718ee
authored
Mar 24, 2011
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZMQ_HWM type changed to int
Signed-off-by:
Martin Sustrik
<
sustrik@250bpm.com
>
parent
bd9d7715
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
25 additions
and
26 deletions
+25
-26
zmq_getsockopt.txt
doc/zmq_getsockopt.txt
+2
-2
zmq_setsockopt.txt
doc/zmq_setsockopt.txt
+1
-1
options.cpp
src/options.cpp
+4
-4
options.hpp
src/options.hpp
+3
-1
pipe.cpp
src/pipe.cpp
+5
-6
pipe.hpp
src/pipe.hpp
+8
-9
socket_base.cpp
src/socket_base.cpp
+1
-1
test_hwm.cpp
tests/test_hwm.cpp
+1
-2
No files found.
doc/zmq_getsockopt.txt
View file @
507718ee
...
...
@@ -73,7 +73,7 @@ type.
The default 'ZMQ_HWM' value of zero means "no limit".
[horizontal]
Option value type::
uint64_
t
Option value type::
in
t
Option value unit:: messages
Default value:: 0
Applicable socket types:: all
...
...
@@ -348,7 +348,7 @@ EXAMPLE
.Retrieving the high water mark
----
/* Retrieve high water mark into hwm */
int
64_t
hwm;
int hwm;
size_t hwm_size = sizeof (hwm);
rc = zmq_getsockopt (socket, ZMQ_HWM, &hwm, &hwm_size);
assert (rc == 0);
...
...
doc/zmq_setsockopt.txt
View file @
507718ee
...
...
@@ -41,7 +41,7 @@ type.
The default 'ZMQ_HWM' value of zero means "no limit".
[horizontal]
Option value type::
uint64_
t
Option value type::
in
t
Option value unit:: messages
Default value:: 0
Applicable socket types:: all
...
...
src/options.cpp
View file @
507718ee
...
...
@@ -50,11 +50,11 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
switch
(
option_
)
{
case
ZMQ_HWM
:
if
(
optvallen_
!=
sizeof
(
uint64_t
)
)
{
if
(
optvallen_
!=
sizeof
(
int
)
||
*
((
int
*
)
optval_
)
<
0
)
{
errno
=
EINVAL
;
return
-
1
;
}
hwm
=
*
((
uint64_
t
*
)
optval_
);
hwm
=
*
((
in
t
*
)
optval_
);
return
0
;
case
ZMQ_AFFINITY
:
...
...
@@ -169,11 +169,11 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
switch
(
option_
)
{
case
ZMQ_HWM
:
if
(
*
optvallen_
<
sizeof
(
uint64_
t
))
{
if
(
*
optvallen_
<
sizeof
(
in
t
))
{
errno
=
EINVAL
;
return
-
1
;
}
*
((
uint64_
t
*
)
optval_
)
=
hwm
;
*
((
in
t
*
)
optval_
)
=
hwm
;
*
optvallen_
=
sizeof
(
uint64_t
);
return
0
;
...
...
src/options.hpp
View file @
507718ee
...
...
@@ -35,7 +35,9 @@ namespace zmq
int
setsockopt
(
int
option_
,
const
void
*
optval_
,
size_t
optvallen_
);
int
getsockopt
(
int
option_
,
void
*
optval_
,
size_t
*
optvallen_
);
uint64_t
hwm
;
// High-water mark for messages in pipe.
int
hwm
;
uint64_t
affinity
;
blob_t
identity
;
...
...
src/pipe.cpp
View file @
507718ee
...
...
@@ -25,8 +25,7 @@
#include "pipe.hpp"
#include "likely.hpp"
zmq
::
reader_t
::
reader_t
(
object_t
*
parent_
,
pipe_t
*
pipe_
,
uint64_t
lwm_
)
:
zmq
::
reader_t
::
reader_t
(
object_t
*
parent_
,
pipe_t
*
pipe_
,
int
lwm_
)
:
object_t
(
parent_
),
active
(
true
),
pipe
(
pipe_
),
...
...
@@ -163,7 +162,7 @@ void zmq::reader_t::process_pipe_term_ack ()
}
zmq
::
writer_t
::
writer_t
(
object_t
*
parent_
,
pipe_t
*
pipe_
,
reader_t
*
reader_
,
uint64_
t
hwm_
)
:
in
t
hwm_
)
:
object_t
(
parent_
),
active
(
true
),
pipe
(
pipe_
),
...
...
@@ -288,11 +287,11 @@ void zmq::writer_t::process_pipe_term ()
bool
zmq
::
writer_t
::
pipe_full
()
{
return
hwm
>
0
&&
msgs_written
-
msgs_read
==
hwm
;
return
hwm
>
0
&&
msgs_written
-
msgs_read
==
uint64_t
(
hwm
)
;
}
void
zmq
::
create_pipe
(
object_t
*
reader_parent_
,
object_t
*
writer_parent_
,
uint64_
t
hwm_
,
reader_t
**
reader_
,
writer_t
**
writer_
)
in
t
hwm_
,
reader_t
**
reader_
,
writer_t
**
writer_
)
{
// First compute the low water mark. Following point should be taken
// into consideration:
...
...
@@ -314,7 +313,7 @@ void zmq::create_pipe (object_t *reader_parent_, object_t *writer_parent_,
// That done, we still we have to account for the cases where
// HWM < max_wm_delta thus driving LWM to negative numbers.
// Let's make LWM 1/2 of HWM in such cases.
uint64_
t
lwm
=
(
hwm_
>
max_wm_delta
*
2
)
?
in
t
lwm
=
(
hwm_
>
max_wm_delta
*
2
)
?
hwm_
-
max_wm_delta
:
(
hwm_
+
1
)
/
2
;
// Create all three objects pipe consists of: the pipe per se, reader and
...
...
src/pipe.hpp
View file @
507718ee
...
...
@@ -23,19 +23,18 @@
#include "../include/zmq.h"
#include "stdint.hpp"
#include "array.hpp"
#include "ypipe.hpp"
#include "config.hpp"
#include "object.hpp"
#include "stdint.hpp"
namespace
zmq
{
// Creates a pipe. Returns pointer to reader and writer objects.
void
create_pipe
(
object_t
*
reader_parent_
,
object_t
*
writer_parent_
,
uint64_t
hwm_
,
class
reader_t
**
reader_
,
class
writer_t
**
writer_
);
int
hwm_
,
class
reader_t
**
reader_
,
class
writer_t
**
writer_
);
// The shutdown mechanism for pipe works as follows: Either endpoint
// (or even both of them) can ask pipe to terminate by calling 'terminate'
...
...
@@ -57,7 +56,7 @@ namespace zmq
class
reader_t
:
public
object_t
,
public
array_item_t
{
friend
void
create_pipe
(
object_t
*
,
object_t
*
,
uint64_
t
,
friend
void
create_pipe
(
object_t
*
,
object_t
*
,
in
t
,
reader_t
**
,
writer_t
**
);
friend
class
writer_t
;
...
...
@@ -77,7 +76,7 @@ namespace zmq
private
:
reader_t
(
class
object_t
*
parent_
,
pipe_t
*
pipe_
,
uint64_
t
lwm_
);
reader_t
(
class
object_t
*
parent_
,
pipe_t
*
pipe_
,
in
t
lwm_
);
~
reader_t
();
// To be called only by writer itself!
...
...
@@ -100,7 +99,7 @@ namespace zmq
class
writer_t
*
writer
;
// Low watermark for in-memory storage (in bytes).
uint64_
t
lwm
;
in
t
lwm
;
// Number of messages read so far.
uint64_t
msgs_read
;
...
...
@@ -126,7 +125,7 @@ namespace zmq
class
writer_t
:
public
object_t
,
public
array_item_t
{
friend
void
create_pipe
(
object_t
*
,
object_t
*
,
uint64_
t
,
friend
void
create_pipe
(
object_t
*
,
object_t
*
,
in
t
,
reader_t
**
,
writer_t
**
);
public
:
...
...
@@ -155,7 +154,7 @@ namespace zmq
private
:
writer_t
(
class
object_t
*
parent_
,
pipe_t
*
pipe_
,
reader_t
*
reader_
,
uint64_
t
hwm_
);
in
t
hwm_
);
~
writer_t
();
// Command handlers.
...
...
@@ -175,7 +174,7 @@ namespace zmq
reader_t
*
reader
;
// High watermark for in-memory storage (in bytes).
uint64_
t
hwm
;
in
t
hwm
;
// Last confirmed number of messages read from the pipe.
// The actual number can be higher.
...
...
src/socket_base.cpp
View file @
507718ee
...
...
@@ -377,7 +377,7 @@ int zmq::socket_base_t::connect (const char *addr_)
// The total HWM for an inproc connection should be the sum of
// the binder's HWM and the connector's HWM.
int
64_t
hwm
;
int
hwm
;
if
(
options
.
hwm
==
0
||
peer
.
options
.
hwm
==
0
)
hwm
=
0
;
else
...
...
tests/test_hwm.cpp
View file @
507718ee
...
...
@@ -21,7 +21,6 @@
#include <assert.h>
#include "../src/stdint.hpp"
#include "testutil.hpp"
int
main
(
int
argc
,
char
*
argv
[])
...
...
@@ -33,7 +32,7 @@ int main (int argc, char *argv [])
// buffer space should be 4 messages.
void
*
sb
=
zmq_socket
(
ctx
,
ZMQ_PULL
);
assert
(
sb
);
uint64_
t
hwm
=
2
;
in
t
hwm
=
2
;
int
rc
=
zmq_setsockopt
(
sb
,
ZMQ_HWM
,
&
hwm
,
sizeof
(
hwm
));
assert
(
rc
==
0
);
rc
=
zmq_bind
(
sb
,
"inproc://a"
);
...
...
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