Use atomic_cas instead of __sync_bool_compare_and_swap