glib/docs/reference
Marco Trevisan (Treviño) bfdeb37f6e gatomic: Add Compare and Exchange functions that returns the previous value
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;
    }
2022-06-22 23:01:19 +02:00
..
gio build: Move gvdb to a subproject 2022-06-16 10:12:07 +01:00
glib gatomic: Add Compare and Exchange functions that returns the previous value 2022-06-22 23:01:19 +02:00
gobject param: Add g_param_value_is_valid 2022-05-23 15:48:28 -04:00
.gitignore .gitignore manpages (*.1) 2010-05-24 23:21:01 -04:00
AUTHORS Initial revision 1999-08-16 17:58:30 +00:00
COPYING Initial revision 1999-08-16 17:58:30 +00:00
meson.build meson: Use range() instead of listing all stable versions 2022-05-11 14:34:00 -04:00
NEWS Initial revision 1999-08-16 17:58:30 +00:00