A RecursiveMutex is overkill for setting or reading a plain integer. Even a Mutex is overkill, when a plain std::atomic can be used.
This removes 11 lines of code. Also, it is cutting down on the number of locks put on the stack at the same time, which complicates review looking out for potential lock contention.