Should I make my MutexLock volatile?
- by sje397
I have some code in a function that goes something like this:
void foo() {
{ // scope the locker
MutexLocker locker(&mutex);
// do some stuff..
}
bar();
}
The function call bar() also locks the mutex.
I am having an issue whereby the program crashes (for someone else, who has not as yet provided a stack trace or more details) unless the mutex lock inside bar is disabled.
Is it possible that some optimization is messing around with the way I have scoped the locker instance, and if so, would making it volatile fix it? Is that a bad idea?
Thanks.