From f77ca41a6fa588371d9e88d7e868b8bb6a361f09 Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Thu, 12 Nov 2015 22:26:24 +0100 Subject: [PATCH] Fix usage of the double-checked locking (anti-)pattern in the cache manager singleton. --- rtgui/cachemanager.cc | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/rtgui/cachemanager.cc b/rtgui/cachemanager.cc index 3d3702176..0b88ea5f4 100644 --- a/rtgui/cachemanager.cc +++ b/rtgui/cachemanager.cc @@ -30,18 +30,8 @@ CacheManager* CacheManager::getInstance(void) { - static CacheManager* instance_ = 0; - - if ( instance_ == 0 ) { - static MyMutex smutex_; - MyMutex::MyLock lock(smutex_); - - if ( instance_ == 0 ) { - instance_ = new CacheManager(); - } - } - - return instance_; + static CacheManager instance_; + return &instance_; } void CacheManager::init ()