How to implement this thread safe pure function in c++? Can anyone help me?