2023-10-21 01:50:38 +02:00
|
|
|
= zmq_atomic_counter_inc(3)
|
2014-12-23 01:14:38 +01:00
|
|
|
|
|
|
|
|
2023-10-21 01:50:38 +02:00
|
|
|
== NAME
|
2014-12-23 01:14:38 +01:00
|
|
|
zmq_atomic_counter_inc - increment an atomic counter
|
|
|
|
|
|
|
|
|
2023-10-21 01:50:38 +02:00
|
|
|
== SYNOPSIS
|
2014-12-23 01:14:38 +01:00
|
|
|
*int zmq_atomic_counter_inc (void *counter);*
|
|
|
|
|
|
|
|
|
2023-10-21 01:50:38 +02:00
|
|
|
== DESCRIPTION
|
2014-12-23 01:14:38 +01:00
|
|
|
The _zmq_atomic_counter_inc_ function increments an atomic counter in a
|
|
|
|
threadsafe fashion. This function uses platform specific atomic
|
|
|
|
operations.
|
|
|
|
|
|
|
|
|
2023-10-21 01:50:38 +02:00
|
|
|
== RETURN VALUE
|
2014-12-23 01:14:38 +01:00
|
|
|
The _zmq_atomic_counter_inc()_ function returns the old value of the
|
|
|
|
counter, before incrementing.
|
|
|
|
|
|
|
|
|
2023-10-21 01:50:38 +02:00
|
|
|
== EXAMPLE
|
2014-12-23 01:14:38 +01:00
|
|
|
.Test code for atomic counters
|
|
|
|
----
|
|
|
|
void *counter = zmq_atomic_counter_new ();
|
|
|
|
assert (zmq_atomic_counter_value (counter) == 0);
|
|
|
|
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);
|
2014-12-23 15:20:10 +01:00
|
|
|
assert (zmq_atomic_counter_dec (counter) == 1);
|
|
|
|
assert (zmq_atomic_counter_dec (counter) == 1);
|
|
|
|
assert (zmq_atomic_counter_dec (counter) == 0);
|
2014-12-23 01:14:38 +01:00
|
|
|
zmq_atomic_counter_set (counter, 2);
|
2014-12-23 15:20:10 +01:00
|
|
|
assert (zmq_atomic_counter_dec (counter) == 1);
|
|
|
|
assert (zmq_atomic_counter_dec (counter) == 0);
|
2014-12-23 01:14:38 +01:00
|
|
|
zmq_atomic_counter_destroy (&counter);
|
2014-12-23 15:20:10 +01:00
|
|
|
return 0;
|
2014-12-23 01:14:38 +01:00
|
|
|
----
|
|
|
|
|
|
|
|
|
2023-10-21 01:50:38 +02:00
|
|
|
== SEE ALSO
|
2023-11-03 11:36:47 +01:00
|
|
|
* xref:zmq_atomic_counter_new.adoc[zmq_atomic_counter_new]
|
|
|
|
* xref:zmq_atomic_counter_set.adoc[zmq_atomic_counter_set]
|
|
|
|
* xref:zmq_atomic_counter_dec.adoc[zmq_atomic_counter_dec]
|
|
|
|
* xref:zmq_atomic_counter_value.adoc[zmq_atomic_counter_value]
|
|
|
|
* xref:zmq_atomic_counter_destroy.adoc[zmq_atomic_counter_destroy]
|
2014-12-23 01:14:38 +01:00
|
|
|
|
|
|
|
|
2023-10-21 01:50:38 +02:00
|
|
|
== AUTHORS
|
2014-12-23 01:14:38 +01:00
|
|
|
This page was written by the 0MQ community. To make a change please
|
2023-11-22 23:18:23 +01:00
|
|
|
read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
|