Search code examples
c++clinuxmultithreadinglock-free

Thread-safe, lock-free increment function?


UPDATED: Is there a thread-safe, lock-free and available on all Linux distros increment function available in C or C++ ?


Solution

  • GLib has functions to do this. You might check out http://library.gnome.org/devel/glib/stable/glib-Atomic-Operations.html

    Specifically, it sounds like you want g_atomic_int_inc()