use non-locking state machine based on atomic reference