perform_atomic is now reentrant and supports blocks that contain return statements
better concurrency safety