mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
bfdeb37f6e
Atomic primitives allow to do conditional compare and exchange but also to get the value that was previously stored in the atomic variable. Now, we provided an exchange function that allows to do an exchange if the atomic value matches an expected value but we had no way to know at the same time what was the value in the atomic at the moment of the exchange try, an this can be useful in case that the operation fails, for example if the current value is still acceptable for us, allowing to do a kind of "OR" check: gint old_value; gint valid_value = 222; while (!g_atomic_pointer_compare_and_exchange_value (&atomic, valid_value, 555, &old_value) { if (old_value == 555 || old_value == 222) valid_value = old_value; } |
||
---|---|---|
.. | ||
reference | ||
backports.md | ||
CODEOWNERS | ||
debugging.txt | ||
macros.txt | ||
meson-version.md | ||
rationales.md | ||
roadmap.md | ||
supported-platforms.md | ||
toolchain-requirements.md |