ZMQ_ATOMIC_COUNTER_S(3)
π zmq_atomic_counter_set(3) β the 0MQ Manual, bestie edition
okay so we're in the 0MQ manual and today's episode is zmq_atomic_counter_set(3), aka the girl whose whole job is just setting a number. no drama, no notes, she simply serves.
β¨ NAME β¨
zmq_atomic_counter_set β set atomic counter to new value
π SYNOPSIS π
void zmq_atomic_counter_set (void *counter, int value);
that's it. that's the whole signature. short queen π
π¦ DESCRIPTION π¦
so zmq_atomic_counter_set sets the counter to a new value, and it does it in a threadsafe fashion β meaning multiple threads can be doing their little thing and it's still gonna behave. no cap.
the largest value that is guaranteed to work across all platforms is 2^31-1. so like, stay in that lane, bestie, unless you enjoy chaos.
under the hood this function uses platform specific atomic operations. it's giving "I don't do the work myself, I delegate to the locals" and honestly? respect.
π RETURN VALUE π
zmq_atomic_counter_set() has no return value. it returns nothing. void. it says its piece and leaves. main character energy fr fr.
πΈ EXAMPLE πΈ
test code for atomic counters, here it is, verbatim, character for character, do not touch:
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;
look at her go β new counter, zero, increment up to 3, decrement back down, then zmq_atomic_counter_set (counter, 2) swoops in and just resets the vibe, and the decs pick up from there. ate. π₯
π SEE ALSO π
zmq_atomic_counter_new(3)zmq_atomic_counter_inc(3)zmq_atomic_counter_dec(3)zmq_atomic_counter_value(3)zmq_atomic_counter_destroy(3)
the whole friend group, go say hi π«Ά
π 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. (yes, that's the real link, yes, it's a colon, no, I'm not editing it, it's not mine to edit π)
0MQ 4.3.5 Β· 10/09/2023 Β· that's the version and the date, babes β and that's the whole page. mwah π zmq_atomic_counter_set(3) out. β¨
π¦ 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