title: How can I effectively use callbacks with boost::progress_display?
body: <p>I would like to use callbacks with boost::progress_display. Firstly I have a class Foo that I need to broadcast events from:</p>
  
  <pre><code>class Foo
  {
    public:
      template &lt;typename L&gt;
      void attachListener(L const &amp;listener)
      {
          m_callback.connect(listener);
      }
  
      void doWork()
      {
          for(...stuff...) {
              m_callback(m_someData);
          }
      }
    private:
      Data m_someData;
      boost::signals2::signal&lt;void(Data const&amp;)&gt; m_callback;
  
  }
  </code></pre>
  
  <p>Then, in some other code, I have a callback that is used to handle events coming from Foo. I then create a Foo in otherFunction and attach callback to it:</p>
  
  <pre><code>void callback(Data const &amp;someData, boost::progress_display &amp;pd)
  {
     // other stuff
     ++pd;
  }
  
  void otherFunction()
  {
      boost::progress_display pd(100); 
      boost::function&lt;void(Data const&amp;)&gt; f(boost::bind(&amp;callback, _1, boost::ref(pd)));
      Foo foo;
      foo.attachListener(f);
      foo.doWork();
  }
  </code></pre>
  
  <p>When the above is run, the callback will be called from Foo::doWork. </p>
  
  <p>Is this the correct way to use callbacks in combination with boost::progress_display?</p>
  
  <p>It can become annoying where I need to create and attach multiple handlers each with their own boost::progress_display. Doing this would mean that each individual progress_display percentage bar is printed out one after the other.</p>
  
  <p>Thanks,
  Ben.</p>