
On 07/26/2010 04:01 PM, Anthony Williams wrote:
Undefined behaviour --- all concurrent calls to condition_variable::wait must use the same mutex. You can use different mutexes with condition_variable_any, and you can use different mutexes for separate waits, but not for concurrent ones.
That pattern was indeed the result of a bug in our application. I was wondering if that can be spotted with a runtime error (or an assert for the matter) at least with NDEBUG not defined, for example the condition_variable::wait can check with __sync_bool_compare_and_swap if it's running concurrently with another call with a different mutex. I'm actualy using the above technique to spot if someone is using a not thread safe class concurrently from different threads. Regards Gaetano Mendola