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

Side by Side Diff: base/lazy_instance.cc

Issue 3956003: ThreadRestrictions: leak the thread local variable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better impl Created 10 years, 2 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) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 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/platform_thread.h"
(...skipping 19 matching lines...) Expand all
30 } 30 }
31 31
32 void LazyInstanceHelper::CompleteInstance(void* instance, void (*dtor)(void*)) { 32 void LazyInstanceHelper::CompleteInstance(void* instance, void (*dtor)(void*)) {
33 // See the comment to the corresponding HAPPENS_AFTER in Pointer(). 33 // See the comment to the corresponding HAPPENS_AFTER in Pointer().
34 ANNOTATE_HAPPENS_BEFORE(&state_); 34 ANNOTATE_HAPPENS_BEFORE(&state_);
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 base::AtExitManager::RegisterCallback(dtor, instance); 40 if (dtor)
41 base::AtExitManager::RegisterCallback(dtor, instance);
41 } 42 }
42 43
43 } // namespace base 44 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698