title: Null pointer check thread safety
body: <p>I am protecting pointer with mutex for writes already like this</p>
  
  <pre><code>// thread1
  if(pointer)
  {
     boost::mutex::scoped_lock lock(pointer_mutex);
     if(pointer)
        pointer-&gt;DoStuff();
  }
  
  // thread2
  if(pointer)
  {
     boost::mutex::scoped_lock lock(pointer_mutex);
     if(pointer)
        pointer = anotherPointer;
  }
  
  // thread3
  if(pointer)
  {
     boost::mutex::scoped_lock lock(pointer_mutex);
     pointer = 0;
  }
  </code></pre>
  
  <p>i do not want want to put that mutex outside of the block, because pointer is null 99.999 of the time.</p>
  
  <p>this works fine with no crashes, but i not experienced enough declare it thread safe.</p>
  
  <p>my question is:</p>
  
  <p>Are if(pointer) pointer = 0;  pointer = anotherPointer; atomic?</p>
  
  <p>Thank you.</p>