title: boost accumulator rolling count non zero
body: <p>I am trying to use accumulators to find out statistics for a given activity per sec. Below are the two stats I would like to compute</p>
  <ul>
  <li><p>Number of times activity has been triggered</p>
  </li>
  <li><p>Sum of the total weight triggered by the activity.</p>
  <p>To achieve I have assumed a granularity by 10 msecs and considering 100 buckets ( per sec ).</p>
  </li>
  <li><p>Actvity Thread inserts into accumulator whenever there is an event</p>
  </li>
  <li><p>Null Activity Thread wakes up every 10 msecs to insert 0 in the weight.</p>
  </li>
  </ul>
  <p>Psuedo code below</p>
  <pre><code>#include &lt;boost/accumulators/accumulators.hpp&gt;
  #include &lt;boost/accumulators/statistics/stats.hpp&gt;
  #include &lt;boost/accumulators/statistics/rolling_count.hpp&gt;
  #include &lt;boost/accumulators/statistics/rolling_sum.hpp&gt;
  
  using namespace boost::accumulators;
  
  #define MAX_WEIGHT 100
  #define MAX_ACIVITY 10
  
  accumulator_set&lt;double, features&lt;tag::rolling_count, tag::rolling_sum&gt; &gt; acc(tag::rolling_window::window_size = 100);
  
  void null_run()//invoked every 10 msecs 
  {
    //mutex protected
    acc(0);
  }
  
  void activity_triggered(int weight) // triggered by an external event
  {
    //mutex protected
    acc(weight);
    if (checkStatus() == false)
    {
      printf(&quot;Max quantity per sec reached stop &quot;);
      exit()
    }
  }
  
  
  bool checkStatus()
  {
     int weightPerSec  = rolling_sum(acc);
     //here I would like to get the count only if non zero may be rolling_count_non_zero()??
     int acitivitiesPersec = rolling_count(acc); 
     
     if (weightPerSec &gt; MAX_WEIGHT)
       return false;
     if (acitivitiesPersec &gt; MAX_ACTIVITY)
       return false;
     return true;
  }
  </code></pre>
  <p>Using above technique i am able to achieve weight entered in the last second but how do I achieve how many times has the activity been triggered in the last sec using boost accumulators ?</p>