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

Side by Side Diff: base/task_scheduler/task_traits_for_current_thread.cc

Issue 2546773002: TaskScheduler: Add internal::GetTaskPriorityForCurrentThread(). (Closed)
Patch Set: self-review Created 4 years 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
OLDNEW
(Empty)
1 // Copyright 2016 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/task_scheduler/task_traits_for_current_thread.h"
6
7 #include "base/lazy_instance.h"
8 #include "base/threading/thread_local.h"
9
10 namespace base {
11 namespace internal {
12
13 namespace {
14
15 LazyInstance<ThreadLocalPointer<const TaskTraits>>::Leaky
16 tls_traits_for_current_thread = LAZY_INSTANCE_INITIALIZER;
17
18 } // namespace
19
20 ScopedSetTaskTraitsForCurrentThread::ScopedSetTaskTraitsForCurrentThread(
21 const TaskTraits* traits)
robliao 2016/12/01 18:12:01 Crazy thought. Can this simply be a const TaskTrai
fdoray 2016/12/01 19:16:02 n/a with TaskPriority
22 #if DCHECK_IS_ON()
23 : traits_(traits)
24 #endif
25 {
26 DCHECK(!GetTaskTraitsForCurrentThread());
27 DCHECK(traits);
28 tls_traits_for_current_thread.Get().Set(traits);
29 }
30
31 ScopedSetTaskTraitsForCurrentThread::~ScopedSetTaskTraitsForCurrentThread() {
32 #if DCHECK_IS_ON()
33 DCHECK_EQ(traits_, GetTaskTraitsForCurrentThread());
gab 2016/12/01 18:04:39 Is this necessary? As long as we DCHECK == null in
fdoray 2016/12/01 19:16:02 Not necessary. Do you still want me to remove it w
34 #endif
35 tls_traits_for_current_thread.Get().Set(nullptr);
36 }
37
38 const TaskTraits* GetTaskTraitsForCurrentThread() {
39 return tls_traits_for_current_thread.Get().Get();
40 }
41
42 } // namespace internal
43 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/task_traits_for_current_thread.h ('k') | base/task_scheduler/task_traits_for_current_thread_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698