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

Side by Side Diff: base/single_thread_task_runner.cc

Issue 10210008: Make MessageLoopProxy::current() usable on threads that don't have MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: SingleThreadTaskRunner::current() Created 8 years, 8 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/single_thread_task_runner.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/single_thread_task_runner.h"
6
7 #include "base/lazy_instance.h"
8 #include "base/threading/thread_local.h"
9
10 namespace base {
11
12 namespace {
13
14 base::LazyInstance<base::ThreadLocalPointer<SingleThreadTaskRunner> >
15 lazy_tls_ptr = LAZY_INSTANCE_INITIALIZER;
16
17 } // namespace
18
19 // static
20 scoped_refptr<SingleThreadTaskRunner> SingleThreadTaskRunner::current() {
21 return lazy_tls_ptr.Pointer()->Get();
Ami GONE FROM CHROMIUM 2012/04/25 17:27:55 Can this DCHECK the ret value (see the TODO(darin)
Sergey Ulanov 2012/04/30 20:02:10 Done.
22 }
23
24 // static
25 void SingleThreadTaskRunner::SetCurrent(SingleThreadTaskRunner* new_current) {
26 DCHECK(!current() || !new_current);
Ami GONE FROM CHROMIUM 2012/04/25 17:27:55 WDYT of xor instead of !||! ? DCHECK(current() ^ n
Sergey Ulanov 2012/04/30 20:02:10 ^ is bitwise xor, so I'm not sure it would work wi
27 lazy_tls_ptr.Pointer()->Set(new_current);
28 }
29
30 } // namespace base
OLDNEW
« no previous file with comments | « base/single_thread_task_runner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698