Wenn ich verstehe, wie C++ - Compiler lokale Variablen handhaben, benötigt IsShutdownInProgress()
keine Sperre, da die statische Variable shutdownInProgress
auf dem Stapel abgelegt wird. Hab ich recht?Mutex beim Zurückgeben des Objektwerts
class MyClass
{
private:
// Irrelevant code commented away
static pthread_mutex_t mutex;
static bool shutdownInProgress;
public:
static void ShutdownIsInProgress()
{
pthread_mutex_lock(mutex);
shutdownInProgress = true;
pthread_mutex_unlock(mutex);
}
static bool IsShutdownInProgress()
{
// pthread_mutex_lock(mutex);
// pthread_mutex_unlock(mutex);
return shutdownInProgress;
}
}