1ZMQ_ATOMIC_COUNTER_V(3)           0MQ Manual           ZMQ_ATOMIC_COUNTER_V(3)
2
3
4

NAME

6       zmq_atomic_counter_value - return value of atomic counter
7

SYNOPSIS

9       int zmq_atomic_counter_value (void *counter);
10

DESCRIPTION

12       The zmq_atomic_counter_value function returns the value of an atomic
13       counter created by zmq_atomic_counter_new(). This function uses
14       platform specific atomic operations.
15

RETURN VALUE

17       The zmq_atomic_counter_value() function returns the value of the atomic
18       counter. If counter does not point to an atomic counter created by
19       zmq_atomic_counter_new(), the behaviour is undefined.
20

EXAMPLE

22       Test code for atomic counters.
23
24           void *counter = zmq_atomic_counter_new ();
25           assert (zmq_atomic_counter_value (counter) == 0);
26           assert (zmq_atomic_counter_inc (counter) == 0);
27           assert (zmq_atomic_counter_inc (counter) == 1);
28           assert (zmq_atomic_counter_inc (counter) == 2);
29           assert (zmq_atomic_counter_value (counter) == 3);
30           assert (zmq_atomic_counter_dec (counter) == 1);
31           assert (zmq_atomic_counter_dec (counter) == 1);
32           assert (zmq_atomic_counter_dec (counter) == 0);
33           zmq_atomic_counter_set (counter, 2);
34           assert (zmq_atomic_counter_dec (counter) == 1);
35           assert (zmq_atomic_counter_dec (counter) == 0);
36           zmq_atomic_counter_destroy (&counter);
37           return 0;
38
39

SEE ALSO

41       zmq_atomic_counter_new(3) zmq_atomic_counter_set(3)
42       zmq_atomic_counter_inc(3) zmq_atomic_counter_dec(3)
43       zmq_atomic_counter_destroy(3)
44

AUTHORS

46       This page was written by the 0MQ community. To make a change please
47       read the 0MQ Contribution Policy at
48       http://www.zeromq.org/docs:contributing.
49
50
51
520MQ 4.3.4                         07/23/2021           ZMQ_ATOMIC_COUNTER_V(3)
Impressum