diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-21 18:58:11 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-21 18:58:11 +0000 |
commit | b727b041c938d45e82d2c42172f79533f1d196be (patch) | |
tree | 85025d4c956692e1e02a98730c6fda14b376fca4 /base | |
parent | c053beb42819d487dc1f41ff40bb82417fee98ed (diff) | |
download | chromium_src-b727b041c938d45e82d2c42172f79533f1d196be.zip chromium_src-b727b041c938d45e82d2c42172f79533f1d196be.tar.gz chromium_src-b727b041c938d45e82d2c42172f79533f1d196be.tar.bz2 |
Add a warning to the top of base/memory/singleton.h
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7217014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89870 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/memory/singleton.h | 14 |
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 |