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

Side by Side Diff: jingle/glue/thread_wrapper.cc

Issue 8491043: Allow linker initialization of lazy instance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: thakis comment, renamed LAZY_INSTANCE_INITIALIZER 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 "jingle/glue/thread_wrapper.h" 5 #include "jingle/glue/thread_wrapper.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 jingle_glue { 10 namespace jingle_glue {
11 11
12 struct JingleThreadWrapper::PendingSend { 12 struct JingleThreadWrapper::PendingSend {
13 PendingSend(const talk_base::Message& message_value) 13 PendingSend(const talk_base::Message& message_value)
14 : sending_thread(JingleThreadWrapper::current()), 14 : sending_thread(JingleThreadWrapper::current()),
15 message(message_value), 15 message(message_value),
16 done_event(true, false) { 16 done_event(true, false) {
17 DCHECK(sending_thread); 17 DCHECK(sending_thread);
18 } 18 }
19 19
20 JingleThreadWrapper* sending_thread; 20 JingleThreadWrapper* sending_thread;
21 talk_base::Message message; 21 talk_base::Message message;
22 base::WaitableEvent done_event; 22 base::WaitableEvent done_event;
23 }; 23 };
24 24
25 base::LazyInstance<base::ThreadLocalPointer<JingleThreadWrapper> > 25 base::LazyInstance<base::ThreadLocalPointer<JingleThreadWrapper> >
26 g_jingle_thread_wrapper(base::LINKER_INITIALIZED); 26 g_jingle_thread_wrapper = LAZY_INSTANCE_INITIALIZER;
27 27
28 // static 28 // static
29 void JingleThreadWrapper::EnsureForCurrentThread() { 29 void JingleThreadWrapper::EnsureForCurrentThread() {
30 if (JingleThreadWrapper::current() == NULL) { 30 if (JingleThreadWrapper::current() == NULL) {
31 g_jingle_thread_wrapper.Get().Set( 31 g_jingle_thread_wrapper.Get().Set(
32 new JingleThreadWrapper(MessageLoop::current())); 32 new JingleThreadWrapper(MessageLoop::current()));
33 } 33 }
34 34
35 DCHECK_EQ(talk_base::Thread::Current(), current()); 35 DCHECK_EQ(talk_base::Thread::Current(), current());
36 } 36 }
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 282
283 void JingleThreadWrapper::Stop() { 283 void JingleThreadWrapper::Stop() {
284 NOTREACHED(); 284 NOTREACHED();
285 } 285 }
286 286
287 void JingleThreadWrapper::Run() { 287 void JingleThreadWrapper::Run() {
288 NOTREACHED(); 288 NOTREACHED();
289 } 289 }
290 290
291 } // namespace jingle_glue 291 } // namespace jingle_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698