]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Simplify MemPools::GetInstance()
authorAlex Rousskov <rousskov@measurement-factory.com>
Wed, 30 Mar 2016 16:15:28 +0000 (05:15 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 30 Mar 2016 16:15:28 +0000 (05:15 +1300)
src/mem/Pool.cc

index 42e2e9b1b54684c045a71531d3d44bf3c2367eed..ff7c4e9a7a8e8ff371565d6a1a10049c708d71d0 100644 (file)
@@ -29,13 +29,10 @@ static int Pool_id_counter = 0;
 MemPools &
 MemPools::GetInstance()
 {
-    /* Must use this idiom, as we can be double-initialised
-     * if we are called during static initialisations.
-     */
-    static MemPools *Instance = nullptr;
-    if (!Instance) {
-        Instance = new MemPools;
-    }
+    // We must initialize on first use (which may happen during static
+    // initialization) and preserve until the last user is gone (which
+    // may happen long after main() exit). We currently preserve forever.
+    static MemPools *Instance = new MemPools;
     return *Instance;
 }