1ZMQ_ATOMIC_COUNTER_D(3) 0MQ Manual ZMQ_ATOMIC_COUNTER_D(3)
2
3
4
6 zmq_atomic_counter_destroy - destroy an atomic counter
7
9 void zmq_atomic_counter_destroy (void **counter_p);
10
12 The zmq_atomic_counter_destroy function destroys an atomic counter and
13 nullifies its reference. Pass the address of an atomic counter (void
14 **) rather than the counter itself. You must destroy all counters that
15 you create, to avoid memory leakage. This function uses platform
16 specific atomic operations.
17
19 The zmq_atomic_counter_destroy() function has no return value.
20
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
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_value(3)
44
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_D(3)