ThreadsafeCounter is simply a counter (based on a
may be incremented in a threadsafe manner.
There is only one constructor, the default constructor:
ThreadsafeCounter()-- create new counter starting at zero.
There is only one operation:
TCS.myAdvance(n)-- increment the counter by
n, and return the value of the counter prior to incrementing.
myAdvance is likely to be quite slow as it uses mutexes.
ThreadsafeCounter may be printed; this is intended primarily to
I copied the code from a BOOST example. It's so simple there are obviously no deficiencies!
operator<< is probably not threadsafe (but does that matter?)
No check for overflow!
You cannot query the counter's value without incrementing it.