
The Win32 API provides InterlockedXXX for atomic operations on long data types, e.g. InterlockedIncrement. I am not sure about other OS's, but it should be possible to define an atomic_long class:
class atomic_long { private: long val; public: inline atomic_long & operator++() { InterlockedIncrement( &val ); return( *this ); } // ... };
I think this design could cause problems - presumably, there would need to be a way to test the value of the atomic_long, such as operator==(long), but that could lead to problematic code: if (++myAtomicLong == someValue) //... else //... An easy fix would be to make the return type void. Tom -------------------------------------------------------- NOTICE: If received in error, please destroy and notify sender. Sender does not waive confidentiality or privilege, and use is prohibited.