title: Does a getter function need a mutex?
body: <p>I have a class that is accessed from multiple threads.  Both of its getter and setter functions are guarded with locks.  </p>
  
  <p>Are the locks for the getter functions really needed?  If so, why?</p>
  
  <pre><code>class foo {
  public:
      void setCount (int count) {
          boost::lock_guard&lt;boost::mutex&gt; lg(mutex_);
          count_ = count;
      }
  
      int count () {
          boost::lock_guard&lt;boost::mutex&gt; lg(mutex_); // mutex needed?
          return count_;
      }
  
  private:
      boost::mutex mutex_;
      int count_;
  };
  </code></pre>