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

Side by Side Diff: base/threading/task_runner_handle_internal.h

Issue 2042383004: Introduce TaskRunnerHandle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update comments Created 4 years, 6 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
« no previous file with comments | « base/threading/task_runner_handle.cc ('k') | base/threading/task_runner_handle_unittest.cc » ('j') | 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 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 #ifndef BASE_THREADING_TASK_RUNNER_HANDLE_INTERNAL_H_
6 #define BASE_THREADING_TASK_RUNNER_HANDLE_INTERNAL_H_
7
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10
11 namespace base {
12
13 class SequencedTaskRunner;
14 class SingleThreadTaskRunner;
15 class TaskRunner;
16
17 namespace internal {
18
19 // Holds the state associated with one of the TaskScope variants. Stores the
20 // relevant pointer in a generic TaskRunner pointer and remembers the type
21 // through an enum which makes for fast lookup of which levels of TaskRunners
22 // are available.
23 struct TaskScopeState {
24 TaskScopeState(scoped_refptr<TaskRunner> task_runner);
25 TaskScopeState(scoped_refptr<SequencedTaskRunner> sequenced_task_runner);
26 TaskScopeState(
27 scoped_refptr<SingleThreadTaskRunner> single_thread_task_runner);
28
29 ~TaskScopeState();
30
31 // TaskScope types sorted from least restrictive to most restrictive. Order
32 // is used for quick lookup of available TaskScope type on current thread.
33 enum Type { PARALLEL, SEQUENCED, SINGLE_THREADED };
34
35 const Type type;
36
37 // A generic TaskRunner to store the potentially more specific TaskRunner
38 // which can safely be upcasted if |type| allows.
39 const scoped_refptr<TaskRunner> task_runner;
40
41 private:
42 DISALLOW_COPY_AND_ASSIGN(TaskScopeState);
43 };
44
45 } // namespace internal
46 } // namespace base
47
48 #endif // BASE_THREADING_TASK_RUNNER_HANDLE_INTERNAL_H_
OLDNEW
« no previous file with comments | « base/threading/task_runner_handle.cc ('k') | base/threading/task_runner_handle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698