Skip to content
  • Alexander Larsson's avatar
    Remove atomics from g_clear_object/g_clear_pointer · b1dd594a
    Alexander Larsson authored
    Practically no caller of these functions require atomic behaviour,
    but the atomics are much slower than normal operations, which makes
    it desirable to get rid of them. We have not done this before because
    that would be a break of the ABI.
    
    However, I recently looked into this and it seems that even if the
    atomics *are* used for g_clear_* it is not ever safe to use this.  The
    atomics protects two threads that are racing to free a global/shared
    object from freeing the object twice. However, any *user* of the global
    object have no protection from the object being freed while in use,
    because there is no paired operation the reads and refs the object
    as an atomic unit (nor can such an operation be implemented using
    purely atomic ops).
    
    So, since nothing could safely have used the atomic aspects of these
    functions I consider it acceptable to just remove it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=733969
    b1dd594a