I would like to check a thread calling different functions of one of my classes. I have a critical time stream, and I do not want anyone to call a function that can call new to call from this stream. However, since the two functions are publicly available, I cannot force it into the language.
My idea is to check the thread id . Assuming that I can guarantee that the call that initializes the thread id is in the correct thread, I would just need to call thread::get_id() in other calls and compare with the thread id that I saved.
The problem is that I also want to test this ID in a critical thread, but I cannot block this thread.
So my question is: is thread::get_id() free (and what could be the worst execution time)?
dzada source share