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
d2bacdf5
Commit
d2bacdf5
authored
Dec 23, 2014
by
Joe Eli McIlvain
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1282 from hintjens/master
Fixed atomic API, which used 'bool'
parents
ae53b27b
eacd4d9c
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
54 additions
and
45 deletions
+54
-45
zmq_atomic_counter_dec.txt
doc/zmq_atomic_counter_dec.txt
+9
-8
zmq_atomic_counter_destroy.txt
doc/zmq_atomic_counter_destroy.txt
+6
-5
zmq_atomic_counter_inc.txt
doc/zmq_atomic_counter_inc.txt
+6
-5
zmq_atomic_counter_new.txt
doc/zmq_atomic_counter_new.txt
+6
-5
zmq_atomic_counter_set.txt
doc/zmq_atomic_counter_set.txt
+6
-5
zmq_atomic_counter_value.txt
doc/zmq_atomic_counter_value.txt
+6
-5
zmq.h
include/zmq.h
+1
-1
zmq_utils.cpp
src/zmq_utils.cpp
+4
-3
test_atomics.cpp
tests/test_atomics.cpp
+5
-5
test_disconnect_inproc.cpp
tests/test_disconnect_inproc.cpp
+4
-2
testutil.hpp
tests/testutil.hpp
+1
-1
No files found.
doc/zmq_atomic_counter_dec.txt
View file @
d2bacdf5
...
...
@@ -9,7 +9,7 @@ zmq_atomic_counter_dec - decrement an atomic counter
SYNOPSIS
--------
*
bool
zmq_atomic_counter_dec (void *counter);*
*
int
zmq_atomic_counter_dec (void *counter);*
DESCRIPTION
...
...
@@ -21,8 +21,8 @@ operations.
RETURN VALUE
------------
The _zmq_atomic_counter_dec()_ function returns
true
if the counter is
greater than zero after decrementing, or
false
if the counter reached
The _zmq_atomic_counter_dec()_ function returns
1
if the counter is
greater than zero after decrementing, or
zero
if the counter reached
zero.
...
...
@@ -36,13 +36,14 @@ assert (zmq_atomic_counter_inc (counter) == 0);
assert (zmq_atomic_counter_inc (counter) == 1);
assert (zmq_atomic_counter_inc (counter) == 2);
assert (zmq_atomic_counter_value (counter) == 3);
assert (zmq_atomic_counter_dec (counter) ==
true
);
assert (zmq_atomic_counter_dec (counter) ==
true
);
assert (zmq_atomic_counter_dec (counter) ==
false
);
assert (zmq_atomic_counter_dec (counter) ==
1
);
assert (zmq_atomic_counter_dec (counter) ==
1
);
assert (zmq_atomic_counter_dec (counter) ==
0
);
zmq_atomic_counter_set (counter, 2);
assert (zmq_atomic_counter_dec (counter) ==
true
);
assert (zmq_atomic_counter_dec (counter) ==
false
);
assert (zmq_atomic_counter_dec (counter) ==
1
);
assert (zmq_atomic_counter_dec (counter) ==
0
);
zmq_atomic_counter_destroy (&counter);
return 0;
----
...
...
doc/zmq_atomic_counter_destroy.txt
View file @
d2bacdf5
...
...
@@ -36,13 +36,14 @@ assert (zmq_atomic_counter_inc (counter) == 0);
assert (zmq_atomic_counter_inc (counter) == 1);
assert (zmq_atomic_counter_inc (counter) == 2);
assert (zmq_atomic_counter_value (counter) == 3);
assert (zmq_atomic_counter_dec (counter) ==
true
);
assert (zmq_atomic_counter_dec (counter) ==
true
);
assert (zmq_atomic_counter_dec (counter) ==
false
);
assert (zmq_atomic_counter_dec (counter) ==
1
);
assert (zmq_atomic_counter_dec (counter) ==
1
);
assert (zmq_atomic_counter_dec (counter) ==
0
);
zmq_atomic_counter_set (counter, 2);
assert (zmq_atomic_counter_dec (counter) ==
true
);
assert (zmq_atomic_counter_dec (counter) ==
false
);
assert (zmq_atomic_counter_dec (counter) ==
1
);
assert (zmq_atomic_counter_dec (counter) ==
0
);
zmq_atomic_counter_destroy (&counter);
return 0;
----
...
...
doc/zmq_atomic_counter_inc.txt
View file @
d2bacdf5
...
...
@@ -35,13 +35,14 @@ assert (zmq_atomic_counter_inc (counter) == 0);
assert (zmq_atomic_counter_inc (counter) == 1);
assert (zmq_atomic_counter_inc (counter) == 2);
assert (zmq_atomic_counter_value (counter) == 3);
assert (zmq_atomic_counter_dec (counter) ==
true
);
assert (zmq_atomic_counter_dec (counter) ==
true
);
assert (zmq_atomic_counter_dec (counter) ==
false
);
assert (zmq_atomic_counter_dec (counter) ==
1
);
assert (zmq_atomic_counter_dec (counter) ==
1
);
assert (zmq_atomic_counter_dec (counter) ==
0
);
zmq_atomic_counter_set (counter, 2);
assert (zmq_atomic_counter_dec (counter) ==
true
);
assert (zmq_atomic_counter_dec (counter) ==
false
);
assert (zmq_atomic_counter_dec (counter) ==
1
);
assert (zmq_atomic_counter_dec (counter) ==
0
);
zmq_atomic_counter_destroy (&counter);
return 0;
----
...
...
doc/zmq_atomic_counter_new.txt
View file @
d2bacdf5
...
...
@@ -36,13 +36,14 @@ assert (zmq_atomic_counter_inc (counter) == 0);
assert (zmq_atomic_counter_inc (counter) == 1);
assert (zmq_atomic_counter_inc (counter) == 2);
assert (zmq_atomic_counter_value (counter) == 3);
assert (zmq_atomic_counter_dec (counter) ==
true
);
assert (zmq_atomic_counter_dec (counter) ==
true
);
assert (zmq_atomic_counter_dec (counter) ==
false
);
assert (zmq_atomic_counter_dec (counter) ==
1
);
assert (zmq_atomic_counter_dec (counter) ==
1
);
assert (zmq_atomic_counter_dec (counter) ==
0
);
zmq_atomic_counter_set (counter, 2);
assert (zmq_atomic_counter_dec (counter) ==
true
);
assert (zmq_atomic_counter_dec (counter) ==
false
);
assert (zmq_atomic_counter_dec (counter) ==
1
);
assert (zmq_atomic_counter_dec (counter) ==
0
);
zmq_atomic_counter_destroy (&counter);
return 0;
----
...
...
doc/zmq_atomic_counter_set.txt
View file @
d2bacdf5
...
...
@@ -35,13 +35,14 @@ assert (zmq_atomic_counter_inc (counter) == 0);
assert (zmq_atomic_counter_inc (counter) == 1);
assert (zmq_atomic_counter_inc (counter) == 2);
assert (zmq_atomic_counter_value (counter) == 3);
assert (zmq_atomic_counter_dec (counter) ==
true
);
assert (zmq_atomic_counter_dec (counter) ==
true
);
assert (zmq_atomic_counter_dec (counter) ==
false
);
assert (zmq_atomic_counter_dec (counter) ==
1
);
assert (zmq_atomic_counter_dec (counter) ==
1
);
assert (zmq_atomic_counter_dec (counter) ==
0
);
zmq_atomic_counter_set (counter, 2);
assert (zmq_atomic_counter_dec (counter) ==
true
);
assert (zmq_atomic_counter_dec (counter) ==
false
);
assert (zmq_atomic_counter_dec (counter) ==
1
);
assert (zmq_atomic_counter_dec (counter) ==
0
);
zmq_atomic_counter_destroy (&counter);
return 0;
----
...
...
doc/zmq_atomic_counter_value.txt
View file @
d2bacdf5
...
...
@@ -34,13 +34,14 @@ assert (zmq_atomic_counter_inc (counter) == 0);
assert (zmq_atomic_counter_inc (counter) == 1);
assert (zmq_atomic_counter_inc (counter) == 2);
assert (zmq_atomic_counter_value (counter) == 3);
assert (zmq_atomic_counter_dec (counter) ==
true
);
assert (zmq_atomic_counter_dec (counter) ==
true
);
assert (zmq_atomic_counter_dec (counter) ==
false
);
assert (zmq_atomic_counter_dec (counter) ==
1
);
assert (zmq_atomic_counter_dec (counter) ==
1
);
assert (zmq_atomic_counter_dec (counter) ==
0
);
zmq_atomic_counter_set (counter, 2);
assert (zmq_atomic_counter_dec (counter) ==
true
);
assert (zmq_atomic_counter_dec (counter) ==
false
);
assert (zmq_atomic_counter_dec (counter) ==
1
);
assert (zmq_atomic_counter_dec (counter) ==
0
);
zmq_atomic_counter_destroy (&counter);
return 0;
----
...
...
include/zmq.h
View file @
d2bacdf5
...
...
@@ -440,7 +440,7 @@ ZMQ_EXPORT int zmq_curve_keypair (char *z85_public_key, char *z85_secret_key);
ZMQ_EXPORT
void
*
zmq_atomic_counter_new
(
void
);
ZMQ_EXPORT
void
zmq_atomic_counter_set
(
void
*
counter
,
int
value
);
ZMQ_EXPORT
int
zmq_atomic_counter_inc
(
void
*
counter
);
ZMQ_EXPORT
bool
zmq_atomic_counter_dec
(
void
*
counter
);
ZMQ_EXPORT
int
zmq_atomic_counter_dec
(
void
*
counter
);
ZMQ_EXPORT
int
zmq_atomic_counter_value
(
void
*
counter
);
ZMQ_EXPORT
void
zmq_atomic_counter_destroy
(
void
**
counter_p
);
...
...
src/zmq_utils.cpp
View file @
d2bacdf5
...
...
@@ -232,11 +232,12 @@ int zmq_atomic_counter_inc (void *counter_)
return
((
zmq
::
atomic_counter_t
*
)
counter_
)
->
add
(
1
);
}
// Decrement the atomic counter and return true if still > zero
// Decrement the atomic counter and return 1 (if counter >= 1), or
// 0 if counter hit zero.
bool
zmq_atomic_counter_dec
(
void
*
counter_
)
int
zmq_atomic_counter_dec
(
void
*
counter_
)
{
return
((
zmq
::
atomic_counter_t
*
)
counter_
)
->
sub
(
1
);
return
((
zmq
::
atomic_counter_t
*
)
counter_
)
->
sub
(
1
)
?
1
:
0
;
}
// Return actual value of atomic counter
...
...
tests/test_atomics.cpp
View file @
d2bacdf5
...
...
@@ -27,12 +27,12 @@ int main (void)
assert
(
zmq_atomic_counter_inc
(
counter
)
==
1
);
assert
(
zmq_atomic_counter_inc
(
counter
)
==
2
);
assert
(
zmq_atomic_counter_value
(
counter
)
==
3
);
assert
(
zmq_atomic_counter_dec
(
counter
)
==
true
);
assert
(
zmq_atomic_counter_dec
(
counter
)
==
true
);
assert
(
zmq_atomic_counter_dec
(
counter
)
==
false
);
assert
(
zmq_atomic_counter_dec
(
counter
)
==
1
);
assert
(
zmq_atomic_counter_dec
(
counter
)
==
1
);
assert
(
zmq_atomic_counter_dec
(
counter
)
==
0
);
zmq_atomic_counter_set
(
counter
,
2
);
assert
(
zmq_atomic_counter_dec
(
counter
)
==
true
);
assert
(
zmq_atomic_counter_dec
(
counter
)
==
false
);
assert
(
zmq_atomic_counter_dec
(
counter
)
==
1
);
assert
(
zmq_atomic_counter_dec
(
counter
)
==
0
);
zmq_atomic_counter_destroy
(
&
counter
);
return
0
;
}
tests/test_disconnect_inproc.cpp
View file @
d2bacdf5
...
...
@@ -25,8 +25,10 @@ zmq_msg_init(&msg) && printf("zmq_msg_init: %s\n", zmq_strerror(errno)); \
zmq_msg_init_size (&msg, size + 1) && printf("zmq_msg_init_size: %s\n",zmq_strerror(errno)); \
memcpy(zmq_msg_data(&msg), data, size + 1);
int
publicationsReceived
=
0
;
bool
isSubscribed
=
false
;
// TODO: this code fails to meet our style guidelines, and needs rewriting
static
int
publicationsReceived
=
0
;
static
bool
isSubscribed
=
false
;
int
main
(
int
,
char
**
)
{
setup_test_environment
();
...
...
tests/testutil.hpp
View file @
d2bacdf5
...
...
@@ -27,7 +27,7 @@
// This defines the settle time used in tests; raise this if we
// get test failures on slower systems due to binds/connects not
// settled. Tested to work reliably at 1 msec on a fast PC.
#define SETTLE_TIME
1
0 // In msec
#define SETTLE_TIME
5
0 // In msec
#undef NDEBUG
#include <time.h>
...
...
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