OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project 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 V8_CANCELABLE_TASK_H_ | 5 #ifndef V8_CANCELABLE_TASK_H_ |
6 #define V8_CANCELABLE_TASK_H_ | 6 #define V8_CANCELABLE_TASK_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "include/v8-platform.h" | 10 #include "include/v8-platform.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 friend class CancelableTaskManager; | 119 friend class CancelableTaskManager; |
120 | 120 |
121 DISALLOW_COPY_AND_ASSIGN(Cancelable); | 121 DISALLOW_COPY_AND_ASSIGN(Cancelable); |
122 }; | 122 }; |
123 | 123 |
124 | 124 |
125 // Multiple inheritance can be used because Task is a pure interface. | 125 // Multiple inheritance can be used because Task is a pure interface. |
126 class CancelableTask : public Cancelable, public Task { | 126 class CancelableTask : public Cancelable, public Task { |
127 public: | 127 public: |
128 explicit CancelableTask(Isolate* isolate); | 128 explicit CancelableTask(Isolate* isolate); |
129 CancelableTask(Isolate* isolate, CancelableTaskManager* manager); | |
130 | 129 |
131 // Task overrides. | 130 // Task overrides. |
132 void Run() final { | 131 void Run() final { |
133 if (TryRun()) { | 132 if (TryRun()) { |
134 RunInternal(); | 133 RunInternal(); |
135 } | 134 } |
136 } | 135 } |
137 | 136 |
138 virtual void RunInternal() = 0; | 137 virtual void RunInternal() = 0; |
139 | 138 |
140 Isolate* isolate() { return isolate_; } | 139 Isolate* isolate() { return isolate_; } |
141 | 140 |
142 private: | 141 private: |
143 Isolate* isolate_; | 142 Isolate* isolate_; |
144 DISALLOW_COPY_AND_ASSIGN(CancelableTask); | 143 DISALLOW_COPY_AND_ASSIGN(CancelableTask); |
145 }; | 144 }; |
146 | 145 |
147 | 146 |
148 // Multiple inheritance can be used because IdleTask is a pure interface. | 147 // Multiple inheritance can be used because IdleTask is a pure interface. |
149 class CancelableIdleTask : public Cancelable, public IdleTask { | 148 class CancelableIdleTask : public Cancelable, public IdleTask { |
150 public: | 149 public: |
151 explicit CancelableIdleTask(Isolate* isolate); | 150 explicit CancelableIdleTask(Isolate* isolate); |
152 CancelableIdleTask(Isolate* isolate, CancelableTaskManager* manager); | |
153 | 151 |
154 // IdleTask overrides. | 152 // IdleTask overrides. |
155 void Run(double deadline_in_seconds) final { | 153 void Run(double deadline_in_seconds) final { |
156 if (TryRun()) { | 154 if (TryRun()) { |
157 RunInternal(deadline_in_seconds); | 155 RunInternal(deadline_in_seconds); |
158 } | 156 } |
159 } | 157 } |
160 | 158 |
161 virtual void RunInternal(double deadline_in_seconds) = 0; | 159 virtual void RunInternal(double deadline_in_seconds) = 0; |
162 | 160 |
163 Isolate* isolate() { return isolate_; } | 161 Isolate* isolate() { return isolate_; } |
164 | 162 |
165 private: | 163 private: |
166 Isolate* isolate_; | 164 Isolate* isolate_; |
167 DISALLOW_COPY_AND_ASSIGN(CancelableIdleTask); | 165 DISALLOW_COPY_AND_ASSIGN(CancelableIdleTask); |
168 }; | 166 }; |
169 | 167 |
170 | 168 |
171 } // namespace internal | 169 } // namespace internal |
172 } // namespace v8 | 170 } // namespace v8 |
173 | 171 |
174 #endif // V8_CANCELABLE_TASK_H_ | 172 #endif // V8_CANCELABLE_TASK_H_ |
OLD | NEW |