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

Side by Side Diff: base/lazy_instance.cc

Issue 580813002: Remove TSan annotations from base/, because ThreadSanitizer v2 doesn't need base::subtle to be anno… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: IWYU for RunningOnValgrind() Created 6 years, 3 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
« no previous file with comments | « base/lazy_instance.h ('k') | base/vlog_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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/threading/platform_thread.h" 10 #include "base/threading/platform_thread.h"
11 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
12 11
13 namespace base { 12 namespace base {
14 namespace internal { 13 namespace internal {
15 14
16 // TODO(joth): This function could be shared with Singleton, in place of its 15 // TODO(joth): This function could be shared with Singleton, in place of its
17 // WaitForInstance() call. 16 // WaitForInstance() call.
18 bool NeedsLazyInstance(subtle::AtomicWord* state) { 17 bool NeedsLazyInstance(subtle::AtomicWord* state) {
19 // Try to create the instance, if we're the first, will go from 0 to 18 // Try to create the instance, if we're the first, will go from 0 to
20 // kLazyInstanceStateCreating, otherwise we've already been beaten here. 19 // kLazyInstanceStateCreating, otherwise we've already been beaten here.
21 // The memory access has no memory ordering as state 0 and 20 // The memory access has no memory ordering as state 0 and
(...skipping 13 matching lines...) Expand all
35 PlatformThread::YieldCurrentThread(); 34 PlatformThread::YieldCurrentThread();
36 } 35 }
37 // Someone else created the instance. 36 // Someone else created the instance.
38 return false; 37 return false;
39 } 38 }
40 39
41 void CompleteLazyInstance(subtle::AtomicWord* state, 40 void CompleteLazyInstance(subtle::AtomicWord* state,
42 subtle::AtomicWord new_instance, 41 subtle::AtomicWord new_instance,
43 void* lazy_instance, 42 void* lazy_instance,
44 void (*dtor)(void*)) { 43 void (*dtor)(void*)) {
45 // See the comment to the corresponding HAPPENS_AFTER in Pointer().
46 ANNOTATE_HAPPENS_BEFORE(state);
47
48 // Instance is created, go from CREATING to CREATED. 44 // Instance is created, go from CREATING to CREATED.
49 // Releases visibility over private_buf_ to readers. Pairing Acquire_Load's 45 // Releases visibility over private_buf_ to readers. Pairing Acquire_Load's
50 // are in NeedsInstance() and Pointer(). 46 // are in NeedsInstance() and Pointer().
51 subtle::Release_Store(state, new_instance); 47 subtle::Release_Store(state, new_instance);
52 48
53 // Make sure that the lazily instantiated object will get destroyed at exit. 49 // Make sure that the lazily instantiated object will get destroyed at exit.
54 if (dtor) 50 if (dtor)
55 AtExitManager::RegisterCallback(dtor, lazy_instance); 51 AtExitManager::RegisterCallback(dtor, lazy_instance);
56 } 52 }
57 53
58 } // namespace internal 54 } // namespace internal
59 } // namespace base 55 } // namespace base
OLDNEW
« no previous file with comments | « base/lazy_instance.h ('k') | base/vlog_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698