ZMQ_ATOMIC_COUNTER_V(3)
β¨ ZMQ_ATOMIC_COUNTER_V(3) β¨
okay bestie, welcome to the 0MQ Manual π β yes we're in section 3, the library-functions girlies.
πΈ NAME πΈ
zmq_atomic_counter_value β return value of atomic counter π
π¦ SYNOPSIS π¦
int zmq_atomic_counter_value (void *counter);
short, sweet, takes a void * and hands you back an int. that's it. that's the whole vibe.
π DESCRIPTION π
so. the zmq_atomic_counter_value function returns the value of an atomic counter that you made earlier with zmq_atomic_counter_new(). like, you built the counter, now you wanna peek at what's inside it. π«Ά
and the way it does that? platform specific atomic operations, no cap. it's not doing anything sketchy, it's just using whatever fancy atomic primitives your platform ships with. lowkey iconic of it honestly. β¨
π RETURN VALUE π
zmq_atomic_counter_value() returns the value of the atomic counter. π
β οΈ bestie. listen. ifcounterdoes NOT point to an atomic counter created byzmq_atomic_counter_new(), the behaviour is undefined. not "a little weird", not "slightly off" β undefined undefined. π so please pass it a real counter. i am begging.
π EXAMPLE π
test code for atomic counters, and honestly it's a little journey: π§
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);
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) == 1);
assert (zmq_atomic_counter_dec (counter) == 0);
zmq_atomic_counter_destroy (&counter);
return 0;
watch it climb 0 β 1 β 2, peek at 3, come back down, get set to 2, come back down again, and then get yeeted by zmq_atomic_counter_destroy. the character development? unmatched. π₯
π SEE ALSO π
zmq_atomic_counter_new(3)zmq_atomic_counter_set(3)zmq_atomic_counter_inc(3)zmq_atomic_counter_dec(3)zmq_atomic_counter_destroy(3)
the whole friend group fr fr π«Ά go read them too.
π AUTHORS π
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. come contribute bestie, the group chat is open. β¨
and that's the whole page!! mwah π this was 0MQ 4.3.5, dated 10/09/2023 β sending you off with kisses and a clean build, bestie. π π πΈ
π¦ where this page comes from
- epel 10: zeromq 4.3.5-18.el10_0 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- fedora 43: zeromq 4.3.5-22.fc43 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- fedora 43: zeromq 4.3.5-22.fc43 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- fedora 44: zeromq 4.3.5-22.fc43 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- fedora 44: zeromq 4.3.5-22.fc43 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- opensuse-leap 16.0: zeromq-devel 4.3.5-160000.2.2 Β· MPL-2.0
- opensuse-leap 16.0: zeromq-devel 4.3.5-160000.2.2 Β· MPL-2.0
- opensuse-leap 16.0: zeromq-devel 4.3.5-160000.2.2 Β· MPL-2.0
- opensuse-leap 16.0: zeromq-devel 4.3.5-160000.2.2 Β· MPL-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms