Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: base/memory/singleton.h

Issue 6714032: Move some files in base to base/memory. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: only base Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_SINGLETON_H_ 5 #ifndef BASE_MEMORY_SINGLETON_H_
6 #define BASE_SINGLETON_H_ 6 #define BASE_MEMORY_SINGLETON_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/atomicops.h" 10 #include "base/atomicops.h"
11 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 11 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
12 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
13 #include "base/threading/thread_restrictions.h" 13 #include "base/threading/thread_restrictions.h"
14 14
15 // Default traits for Singleton<Type>. Calls operator new and operator delete on 15 // Default traits for Singleton<Type>. Calls operator new and operator delete on
16 // the object. Registers automatic deletion at process exit. 16 // the object. Registers automatic deletion at process exit.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // normal process exit). The Trait::Delete function will not be called on 119 // normal process exit). The Trait::Delete function will not be called on
120 // abnormal process exit. 120 // abnormal process exit.
121 // 121 //
122 // DifferentiatingType is used as a key to differentiate two different 122 // DifferentiatingType is used as a key to differentiate two different
123 // singletons having the same memory allocation functions but serving a 123 // singletons having the same memory allocation functions but serving a
124 // different purpose. This is mainly used for Locks serving different purposes. 124 // different purpose. This is mainly used for Locks serving different purposes.
125 // 125 //
126 // Example usage: 126 // Example usage:
127 // 127 //
128 // In your header: 128 // In your header:
129 // #include "base/singleton.h" 129 // #include "base/memory/singleton.h"
130 // class FooClass { 130 // class FooClass {
131 // public: 131 // public:
132 // static FooClass* GetInstance(); <-- See comment below on this. 132 // static FooClass* GetInstance(); <-- See comment below on this.
133 // void Bar() { ... } 133 // void Bar() { ... }
134 // private: 134 // private:
135 // FooClass() { ... } 135 // FooClass() { ... }
136 // friend struct DefaultSingletonTraits<FooClass>; 136 // friend struct DefaultSingletonTraits<FooClass>;
137 // 137 //
138 // DISALLOW_COPY_AND_ASSIGN(FooClass); 138 // DISALLOW_COPY_AND_ASSIGN(FooClass);
139 // }; 139 // };
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 reinterpret_cast<Type*>(base::subtle::NoBarrier_Load(&instance_))); 261 reinterpret_cast<Type*>(base::subtle::NoBarrier_Load(&instance_)));
262 instance_ = 0; 262 instance_ = 0;
263 } 263 }
264 static base::subtle::AtomicWord instance_; 264 static base::subtle::AtomicWord instance_;
265 }; 265 };
266 266
267 template <typename Type, typename Traits, typename DifferentiatingType> 267 template <typename Type, typename Traits, typename DifferentiatingType>
268 base::subtle::AtomicWord Singleton<Type, Traits, DifferentiatingType>:: 268 base::subtle::AtomicWord Singleton<Type, Traits, DifferentiatingType>::
269 instance_ = 0; 269 instance_ = 0;
270 270
271 #endif // BASE_SINGLETON_H_ 271 #endif // BASE_MEMORY_SINGLETON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698