atomicModifyIORef: use a local cas() instead of the global lock