This logic could be simpler—and we could eliminate the scheduler—with `OSAtomicCompareAndSwapIntBarrier`.