summaryrefslogtreecommitdiffstats
path: root/base/memory/singleton.h
diff options
context:
space:
mode:
Diffstat (limited to 'base/memory/singleton.h')
-rw-r--r--base/memory/singleton.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/base/memory/singleton.h b/base/memory/singleton.h
index a387356..10f0981 100644
--- a/base/memory/singleton.h
+++ b/base/memory/singleton.h
@@ -2,6 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// PLEASE READ: Do you really need a singleton?
+//
+// Singletons make it hard to determine the lifetime of an object, which can
+// lead to buggy code and spurious crashes.
+//
+// Instead of adding another singleton into the mix, try to identify either:
+// a) An existing singleton that can manage your object's lifetime
+// b) Locations where you can deterministically create the object and pass
+// into other objects
+//
+// If you absolutely need a singleton, please keep them as trivial as possible
+// and ideally a leaf dependency. Singletons get problematic when they attempt
+// to do too much in their destructor or have circular dependencies.
+
#ifndef BASE_MEMORY_SINGLETON_H_
#define BASE_MEMORY_SINGLETON_H_
#pragma once