title: Is atomic increase and comparsion thread-safe
body: <p>I'm writing multithreaded socket class. BelowBounds() function can be invoked from multiple threads simultaneously, i need to prevent using mutexes. Does this code is thread-safe ?</p>
  
  <pre><code>class UDPSocketHT
  {
  public:
      std::atomic&lt;size_t&gt; m_nSimultaneousRecvCalls;
      std::atomic&lt;size_t&gt; m_nPendingOperations;
      //...
      bool UDPSocketHT::BelowBounds ( )
      {
           return ( !m_nSimultaneousRecvCalls || ( m_nPendingOperations + 1 &lt;= m_nSimultaneousRecvCalls ) ) ? true : false;
      }
  }
  </code></pre>
  
  <p>Or i must write in this way?</p>
  
  <pre><code>bool UDPSocketHT::BelowBounds ( )
  {
       size_t x = m_nSimultaneousRecvCalls;
       size_t y = m_nPendingOperations;
       return ( !x || ( y + 1 &lt;= x) ) ? true : false;
  }
  </code></pre>