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

Side by Side Diff: base/lazy_instance.cc

Issue 6001010: Move platform_thread to base/threading and put in the base namespace. I left ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 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
« no previous file with comments | « base/file_util_unittest.cc ('k') | base/lazy_instance_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 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 #include "base/lazy_instance.h" 5 #include "base/lazy_instance.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/atomicops.h" 8 #include "base/atomicops.h"
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/platform_thread.h" 10 #include "base/threading/platform_thread.h"
11 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 11 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
12 12
13 namespace base { 13 namespace base {
14 14
15 bool LazyInstanceHelper::NeedsInstance() { 15 bool LazyInstanceHelper::NeedsInstance() {
16 // Try to create the instance, if we're the first, will go from EMPTY 16 // Try to create the instance, if we're the first, will go from EMPTY
17 // to CREATING, otherwise we've already been beaten here. 17 // to CREATING, otherwise we've already been beaten here.
18 if (base::subtle::Acquire_CompareAndSwap( 18 if (base::subtle::Acquire_CompareAndSwap(
19 &state_, STATE_EMPTY, STATE_CREATING) == STATE_EMPTY) { 19 &state_, STATE_EMPTY, STATE_CREATING) == STATE_EMPTY) {
20 // Caller must create instance 20 // Caller must create instance
(...skipping 14 matching lines...) Expand all
35 35
36 // Instance is created, go from CREATING to CREATED. 36 // Instance is created, go from CREATING to CREATED.
37 base::subtle::Release_Store(&state_, STATE_CREATED); 37 base::subtle::Release_Store(&state_, STATE_CREATED);
38 38
39 // Make sure that the lazily instantiated object will get destroyed at exit. 39 // Make sure that the lazily instantiated object will get destroyed at exit.
40 if (dtor) 40 if (dtor)
41 base::AtExitManager::RegisterCallback(dtor, instance); 41 base::AtExitManager::RegisterCallback(dtor, instance);
42 } 42 }
43 43
44 } // namespace base 44 } // namespace base
OLDNEW
« no previous file with comments | « base/file_util_unittest.cc ('k') | base/lazy_instance_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698