Use GCC atomics to avoid locking in callback.