C++ thread-safe averaging
Code


Prefer std::array over plain C-style arrays. It has more normal copy / assignment semantics (which admittedly isn't relevant here), but also allows you to access the size directly from the array.
Naming:


head is usually used for the first populated element (of a list, for example). In this case it refers to the first empty space instead, so next might be a more appropriate name.
avg, itr: prefer full names over abbreviations.
_mutex: the underscore prefix is usually used to denote a member, but this is the only member that has one?
sum would be a better name than tmp. It's also better to declare variables as close as possible to the point of use.

double sum = 0.;
for (auto i : data) // range-based for loop for brevity
    sum += i;


Sum loops like this may also be written using the std::accumulate algorithm:

    #include &lt;numeric&gt;
    ...
    using std::begin;
    using std::end;
    auto sum = std::accumulate(begin(data), end(data), 0.0);

When referring to _mutex in member functions, the code uses this-&gt;_mutex. Which rather defeats the point of using the underscore prefix. No other members are referred to with this-&gt;.
The itr and head variables are unnecessary, as they can both be trivially calculated: itr = counter / N; head = counter % N;
Getter functions, e.g.count(), average() should be const. Note that for this to compile, the mutex member must then be made mutable (one of the few instances where mutable is to be recommended).




Design

This appears to be a Cumulative Moving Average. Data storage is actually unnecessary for such an average! (Which can be seen in the existing code since  the data is periodically overwritten. There is no advantage in creating an Average&lt;double, 1297&gt; over an Average&lt;double, 1&gt;. The average() function will return the same result for the same data regardless.)

Since the data is private and cannot be accessed externally, it becomes irrelevant... As such, most of the code can be deleted! :)

class CumulativeMovingAverage
{
    std::size_t n;
    double average;

public:

    CumulativeMovingAverage(): n(0u), average(0.0) { }

    std::size_t get_count() const
    {
        return n;
    }

    double get_average() const
    {
        return average;
    }

    void update(double x)
    {
        // formula straight from wikipedia:
        //average = (x + n * average) / (n + 1u);
        //++n;

        // improved formula from Toby Speight (see comments):
        ++n;
        average += (x - average) / n;
    }
};


Thread safety / templateyness is left as an exercise to the reader (the original code looks correct to me).