Do I need to mutex or lock when calling ResetEvent()?
c++, multithreading, windows
Solution
This extra mutex is almost certainly unneeded. The `ResetEvent` and `SetEvent` functions themselves are safe to call from multiple threads
Given that this code does exists it seems highly likely that the developer who wrote that code didn't understand the threading semantics they'd created. I would treat any code depending on that logic as highly suspect. It'd probably save you some time in the long run to go ahead and pre-audit that code for threading issues
Problem
I've inherited some code like this: ``` m_mutex.Lock(); ResetEvent( m_hSyncObject ); m_mutex.Unlock(); ``` Same for `SetEvent()` Are those Mutexes necessary in this case - do those calls behave themselves or can I get away with removing the locks? This function has already had some inc/decs of values that I made atomic earlier and now just these events are within the locks, so getting rid of them would be a big win if possible.