ScopedLock in inline methods


#1

Can the ScopedLocked be used without thinking about compiler optimization, inline functions and so on??

e.g.

Class1 { // .... inline void method1() { const ScopedLock myScopedLock (myCriticalSection); // do something } };

When doing a release build with optimization, can the locked scope become larger than intended because the code is merged together during inlining?

Thanx for answers
Jan


#2

No, don’t worry about that. The compiler will get the scoping right even if it inlines it. Imagine the havoc that’d break loose if inlining opened up the scope!


#3