© 2012 John Abbott
GNU Free Documentation License, Version 1.2

CoCoALib Documentation Index

User documentation for ThreadsafeCounter

A ThreadsafeCounter is simply a counter (based on a long) which may be incremented in a threadsafe manner.


There is only one constructor, the default constructor:

Operations on ThreadsafeCounters

There is only one operation:

Note that myAdvance is likely to be quite slow as it uses mutexes.

A ThreadsafeCounter may be printed; this is intended primarily to permit debugging.

Maintainer documentation

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?)

Bugs, shortcomings and other ideas

No check for overflow!

You cannot query the counter's value without incrementing it.

Main changes