I have a map defined like this.
typedef std::map< tstring, unsigned int > ErrorToCount_T;
ErrorToCount_T m_ErrorToSuppress;
I am using like it like this.
ErrorToCount_T::iterator itr = m_ErrorToSuppress.find( val );
if( itr != m_ErrorToSuppress.end())
{
if( (itr->second) % m_LogFreq == 0)
//Do something
else
//Do something else
InterlockedIncrement( &itr->second);
}
I saw this and I understand that find is thread-safe. But I was thinking that InterlockedIncrement( &itr->second) will be threadsafe too? Is the above code thread safe. There are absolutely no inserts in this map in multithreaded environment.