OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_RASTER_TASK_H_ | 5 #ifndef CC_RASTER_TASK_H_ |
6 #define CC_RASTER_TASK_H_ | 6 #define CC_RASTER_TASK_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "cc/base/cc_export.h" | 13 #include "cc/base/cc_export.h" |
14 | 14 |
15 namespace cc { | 15 namespace cc { |
16 class Task; | 16 class Task; |
17 | 17 |
18 // States to manage life cycle of a task. Task gets created with NEW state and | 18 // This class provides states to manage life cycle of a task and given below is |
19 // concludes either in FINISHED or CANCELLED state. So possible life cycle | 19 // how it is used by TaskGraphWorkQueue to process life cycle of a task. |
20 // paths for task are - | 20 // Task is in NEW state when it is created. When task is added to |
21 // NEW -> SCHEDULED -> RUNNING -> FINISHED | 21 // |ready_to_run_tasks| then its state is changed to SCHEDULED. Task can be |
22 // NEW -> SCHEDULED -> CANCELED | 22 // canceled from NEW state (not yet scheduled to run) or from SCHEDULED state, |
| 23 // when new ScheduleTasks() is triggered and its state is changed to CANCELED. |
| 24 // When task is about to run it is added |running_tasks| and its state is |
| 25 // changed to RUNNING. Once task finishes running, its state is changed to |
| 26 // FINISHED. Both CANCELED and FINISHED tasks are added to |completed_tasks|. |
| 27 // ╔═════╗ |
| 28 // +------║ NEW ║------+ |
| 29 // | ╚═════╝ | |
| 30 // v v |
| 31 // ┌───────────┐ ╔══════════╗ |
| 32 // │ SCHEDULED │------> ║ CANCELED ║ |
| 33 // └───────────┘ ╚══════════╝ |
| 34 // | |
| 35 // v |
| 36 // ┌─────────┐ ╔══════════╗ |
| 37 // │ RUNNING │-------> ║ FINISHED ║ |
| 38 // └─────────┘ ╚══════════╝ |
23 class CC_EXPORT TaskState { | 39 class CC_EXPORT TaskState { |
24 public: | 40 public: |
25 bool IsScheduled() const; | 41 bool IsScheduled() const; |
26 bool IsRunning() const; | 42 bool IsRunning() const; |
27 bool IsFinished() const; | 43 bool IsFinished() const; |
28 bool IsCanceled() const; | 44 bool IsCanceled() const; |
29 | 45 |
30 // Functions to change the state of task. These functions should be called | 46 // Functions to change the state of task. These functions should be called |
31 // only from TaskGraphWorkQueue where the life cycle of a task is decided or | 47 // only from TaskGraphWorkQueue where the life cycle of a task is decided or |
32 // from tests. These functions are not thread-safe. Caller is responsible for | 48 // from tests. These functions are not thread-safe. Caller is responsible for |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 void Swap(TaskGraph* other); | 133 void Swap(TaskGraph* other); |
118 void Reset(); | 134 void Reset(); |
119 | 135 |
120 Node::Vector nodes; | 136 Node::Vector nodes; |
121 Edge::Vector edges; | 137 Edge::Vector edges; |
122 }; | 138 }; |
123 | 139 |
124 } // namespace cc | 140 } // namespace cc |
125 | 141 |
126 #endif // CC_RASTER_TASK_H_ | 142 #endif // CC_RASTER_TASK_H_ |
OLD | NEW |