Index: base/single_thread_task_runner.cc |
diff --git a/base/single_thread_task_runner.cc b/base/single_thread_task_runner.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c0d0d50242701a0269b817480363fa65e5bd02b4 |
--- /dev/null |
+++ b/base/single_thread_task_runner.cc |
@@ -0,0 +1,30 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/single_thread_task_runner.h" |
+ |
+#include "base/lazy_instance.h" |
+#include "base/threading/thread_local.h" |
+ |
+namespace base { |
+ |
+namespace { |
+ |
+base::LazyInstance<base::ThreadLocalPointer<SingleThreadTaskRunner> > |
+ lazy_tls_ptr = LAZY_INSTANCE_INITIALIZER; |
+ |
+} // namespace |
+ |
+// static |
+scoped_refptr<SingleThreadTaskRunner> SingleThreadTaskRunner::current() { |
+ 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.
|
+} |
+ |
+// static |
+void SingleThreadTaskRunner::SetCurrent(SingleThreadTaskRunner* new_current) { |
+ 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
|
+ lazy_tls_ptr.Pointer()->Set(new_current); |
+} |
+ |
+} // namespace base |