title: A non-reentrant function in an API being used in a multi-threaded program
body: <p>I've using the QT API in C++, but I imagine answers can come effectively from people without any prior experience with QT.</p>
  
  <p>QT has a function in its XML-handling class, called setContent(), which is specified as non-reentrant. When called, setContent() reads an XML file into memory, and returns it as a data structure.</p>
  
  <p>As I understand it, a non-reentrant function is one that is not safe to call simultaneously from multiple threads even if the function is called to operate on different files/objects.</p>
  
  <p>So based on this, my understanding is that I would not be able to have more than one thread that opens XML files using this function unless somehow both of these threads are protected against accessing the setContent() function at the same time.</p>
  
  <p>Is this correct? If so, seems like a really poor way to write an API as this doesn't seem like a function at all that intuitively would raise multi-threading problems. In addition, no mutex is provided at all by <a href="http://doc.qt.nokia.com/latest/qdomdocument.html" rel="nofollow">the API</a>.</p>
  
  <p>So in order to use this function in my multi-threaded program, where more than one thread will be opening different XML files, what's the best way to handle access to the setContent() function? Should I create an extern mutex in a header file on its own that is included by every file that will access XML?</p>