ZMQ_ATOMIC_COUNTER_N(3)
β¨ ZMQ_ATOMIC_COUNTER_N(3) β¨
okay so bestie, this is a page from the 0MQ Manual and we're about to get so into it π
π NAME π
zmq_atomic_counter_new β create a new atomic counter π
π¦ SYNOPSIS π¦
void *zmq_atomic_counter_new (void);
πΈ DESCRIPTION πΈ
So the zmq_atomic_counter_new function creates a new atomic counter. That's it, that's the job π
You can use this in multithreaded applications to do, for example, reference counting of shared objects. Like, multiple threads all touching the same counter and nobody's stepping on anybody's toes. iconic behaviour fr fr.
The atomic counter is at least 32 bits large. Yes, at least β she's not gonna be tiny, don't worry.
This function uses platform specific atomic operations. iykyk π₯
β RETURN VALUE β
The zmq_atomic_counter_new() function returns the new atomic counter if successful. Otherwise it returns NULL. π
not theNULLjump scare. bestie, if you seeNULLcome back, something went wrong and you gotta handle it, okay? π«Ά
π EXAMPLE π
Test code for atomic counters. 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;
the way she increments and decrements and never once loses countβ¦ main character energy, no cap π
π SEE ALSO π
zmq_atomic_counter_set(3)zmq_atomic_counter_inc(3)zmq_atomic_counter_dec(3)zmq_atomic_counter_value(3)zmq_atomic_counter_destroy(3)
go read her sisters, they're all slaying in their own lanes π
π 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.
and that's the whole page, bestie π this was 0MQ 4.3.5, dated 10/09/2023, and honestly? she ate. mwah π
β¨
π¦ 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