ZMQ_ATOMIC_COUNTER_D(3)
π ZMQ_ATOMIC_COUNTER_D(3) β the 0MQ manual, bestie edition
okay so real quick, the manual name is 0MQ Manual and this page is ZMQ_ATOMIC_COUNTER_D(3). yes it's giving "I know her". let's get into it π
β¨ NAME β¨
zmq_atomic_counter_dec β decrement an atomic counter. that's it. that's the whole job. she does one thing and she does it well π
β¨ SYNOPSIS β¨
int zmq_atomic_counter_dec (void *counter);
β¨ DESCRIPTION β¨
so like, the zmq_atomic_counter_dec function decrements an atomic counter in a threadsafe fashion, no cap. π§΅β¨
and the way it does that? it uses platform specific atomic operations. so like, it's not doing anything sketchy, it's letting your platform handle the heavy lifting. trust. π
β¨ RETURN VALUE β¨
zmq_atomic_counter_dec() returns:
1β if the counter is greater than zero after decrementing π«Ά0β if the counter reached zero π
so basically it's telling you "we still got some left" or "we hit the floor". cute, informative, iconic. β
β¨ EXAMPLE β¨
test code for atomic counters, bestie. look at her go:
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;
likeβ¦ she counts up, she counts down, she resets, she does it again, she destroys herself. main character energy fr fr π₯
β¨ SEE ALSO β¨
go read her friends, they're all slaying too:
zmq_atomic_counter_new(3)zmq_atomic_counter_set(3)zmq_atomic_counter_inc(3)zmq_atomic_counter_value(3)zmq_atomic_counter_destroy(3)
β¨ AUTHORS β¨
this page was written by the 0MQ community π«Ά and if you wanna make a change, please read the 0MQ Contribution Policy at http://www.zeromq.org/docs:contributing. they'd literally love that for you π
and that's a wrap on ZMQ_ATOMIC_COUNTER_D(3), brought to you by 0MQ 4.3.5 and dated 10/09/2023. mwah, go decrement something responsibly π
β¨
π¦ 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