title: Is thread::get_id (C++11) lock free?
body: <p>I would like to <strong>test the thread calling different functions</strong> of one of my classes. I have a critical time thread, and I don't want anyone to call a function that may call <code>new</code> to be called from that thread. However, as the 2 functions are public, I can't enforce it by the language.</p>
  
  <p>My idea is <strong>to test the thread id</strong>. Assuming that I can ensure that the call initializing the thread id is in the right thread, I would just have to call <code>thread::get_id()</code> in other calls and compare to the thread id I saved.</p>
  
  <p>The problem is that <strong>I also want to test in the critical thread this ID but I can not lock in that thread.</strong></p>
  
  <p>Therefore my question is: Is <code>thread::get_id()</code> lock free (and what could be the worst time of execution)?</p>