J
jason.cipriani
Let's say I have something like this, a class that wraps a "Mutex",
locks it on construction and unlocks it when it's destroyed (for
example):
class AutoMutex {
public:
AutoMutex (Mutex &) ... ;
~AutoMutex () ... ;
};
Now let's say I use it in a function that returns a copy of another
complex object:
class Something { ... };
Mutex TheMutex;
Something TheThing;
Something function () {
AutoMutex m(TheMutex);
return TheThing;
}
If I am using, in that example, "TheMutex" to protect access to
"TheThing", will "TheThing" be accessed before or after "m" goes out
of scope and unlocks the mutex?
Thanks,
Jason
locks it on construction and unlocks it when it's destroyed (for
example):
class AutoMutex {
public:
AutoMutex (Mutex &) ... ;
~AutoMutex () ... ;
};
Now let's say I use it in a function that returns a copy of another
complex object:
class Something { ... };
Mutex TheMutex;
Something TheThing;
Something function () {
AutoMutex m(TheMutex);
return TheThing;
}
If I am using, in that example, "TheMutex" to protect access to
"TheThing", will "TheThing" be accessed before or after "m" goes out
of scope and unlocks the mutex?
Thanks,
Jason