title: Overhead of pthread mutexes?
body: <p>I'm trying to make a C++ API (for Linux and Solaris) thread-safe, so that its functions can be called from different threads without breaking internal data structures. In my current approach I'm using pthread mutexes to protect all accesses to member variables. This means that a simple getter function now locks and unlocks a mutex, and I'm worried about the overhead of this, especially as the API will mostly be used in single-threaded apps where any mutex locking seems like pure overhead.</p>
  
  <p>So, I'd like to ask:</p>
  
  <ul>
  <li>do you have any experience with performance of single-threaded apps that use locking versus those that don't?</li>
  <li>how expensive are these lock/unlock calls, compared to eg. a simple "return this->isActive" access for a bool member variable?</li>
  <li>do you know better ways to protect such variable accesses?</li>
  </ul>