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

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: support for parallel tasks from SequencedWorkerPool 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
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 union and remembers the type through an enum which
21 // makes for fast lookup of which levels of TaskRunners are available.
22 struct TaskScopeState {
23 TaskScopeState(scoped_refptr<TaskRunner> task_runner);
24 TaskScopeState(scoped_refptr<SequencedTaskRunner> sequenced_task_runner);
25 TaskScopeState(
26 scoped_refptr<SingleThreadTaskRunner> single_thread_task_runner);
27
28 ~TaskScopeState();
29
30 // TaskScope types sorted from least restrictive to most restrictive. Order
31 // is used for quick lookup of available TaskScope type on current thread.
32 enum Type { PARALLEL, SEQUENCED, SINGLE_THREADED };
33
34 union TaskRunnerUnion {
35 TaskRunnerUnion(scoped_refptr<TaskRunner> task_runner);
36 TaskRunnerUnion(scoped_refptr<SequencedTaskRunner> sequenced_task_runner);
37 TaskRunnerUnion(
38 scoped_refptr<SingleThreadTaskRunner> single_thread_task_runner);
39 ~TaskRunnerUnion();
40
41 scoped_refptr<TaskRunner> task_runner;
42 scoped_refptr<SequencedTaskRunner> sequenced_task_runner;
43 scoped_refptr<SingleThreadTaskRunner> single_thread_task_runner;
44 };
45
46 const Type type;
47
48 // A union of TaskRunner types. Since the more specific TaskRunners inherit
49 // from the less specific ones, it is always ok to get a less specific type
50 // after confirming that |type| at least covers that type.
51 const TaskRunnerUnion task_runners;
52
53 private:
54 DISALLOW_COPY_AND_ASSIGN(TaskScopeState);
55 };
56
57 } // namespace internal
58 } // namespace base
59
60 #endif // BASE_THREADING_TASK_RUNNER_HANDLE_INTERNAL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698