2023-10-21 01:50:38 +02:00
|
|
|
= zmq_atomic_counter_set(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_set - set atomic counter to new value
|
|
|
|
|
|
|
|
|
2023-10-21 01:50:38 +02:00
|
|
|
== SYNOPSIS
|
2014-12-23 01:14:38 +01:00
|
|
|
*void zmq_atomic_counter_set (void *counter, int value);*
|
|
|
|
|
|
|
|
|
2023-10-21 01:50:38 +02:00
|
|
|
== DESCRIPTION
|
2014-12-23 01:14:38 +01:00
|
|
|
The _zmq_atomic_counter_set_ function sets the counter to a new value,
|
|
|
|
in a threadsafe fashion. The largest value that is guaranteed to work
|
|
|
|
across all platforms is 2^31-1. 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_set()_ function has no return value.
|
|
|
|
|
|
|
|
|
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_inc.adoc[zmq_atomic_counter_inc]
|
|
|
|
* 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
|
|
|
|
read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.
|