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

Side by Side Diff: content/public/utility/utility_thread.cc

Issue 8491043: Allow linker initialization of lazy instance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: willchan comments + rebase Created 9 years, 1 month 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) 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 "content/public/utility/utility_thread.h" 5 #include "content/public/utility/utility_thread.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/threading/thread_local.h" 8 #include "base/threading/thread_local.h"
9 9
10 namespace content { 10 namespace content {
11 11
12 // Keep the global UtilityThread in a TLS slot so it is impossible to access 12 // Keep the global UtilityThread in a TLS slot so it is impossible to access
13 // incorrectly from the wrong thread. 13 // incorrectly from the wrong thread.
14 static base::LazyInstance<base::ThreadLocalPointer<UtilityThread> > lazy_tls( 14 static base::LazyInstance<base::ThreadLocalPointer<UtilityThread> > lazy_tls =
15 base::LINKER_INITIALIZED); 15 LAZY_INSTANCE_INITIALIZER;
16 16
17 UtilityThread* UtilityThread::Get() { 17 UtilityThread* UtilityThread::Get() {
18 return lazy_tls.Pointer()->Get(); 18 return lazy_tls.Pointer()->Get();
19 } 19 }
20 20
21 UtilityThread::UtilityThread() { 21 UtilityThread::UtilityThread() {
22 lazy_tls.Pointer()->Set(this); 22 lazy_tls.Pointer()->Set(this);
23 } 23 }
24 24
25 UtilityThread::~UtilityThread() { 25 UtilityThread::~UtilityThread() {
26 lazy_tls.Pointer()->Set(NULL); 26 lazy_tls.Pointer()->Set(NULL);
27 } 27 }
28 28
29 } // namespace content 29 } // namespace content
30 30
OLDNEW
« no previous file with comments | « content/public/renderer/render_view_observer_tracker.h ('k') | content/renderer/devtools_agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698