OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef V8_CANCELABLE_TASK_H_ |
| 6 #define V8_CANCELABLE_TASK_H_ |
| 7 |
| 8 #include "include/v8-platform.h" |
| 9 #include "src/base/macros.h" |
| 10 |
| 11 namespace v8 { |
| 12 namespace internal { |
| 13 |
| 14 class Isolate; |
| 15 |
| 16 class CancelableTask : public Task { |
| 17 public: |
| 18 explicit CancelableTask(Isolate* isolate); |
| 19 ~CancelableTask() override; |
| 20 |
| 21 void Cancel() { is_cancelled_ = true; } |
| 22 |
| 23 void Run() final { |
| 24 if (!is_cancelled_) { |
| 25 RunInternal(); |
| 26 } |
| 27 } |
| 28 |
| 29 virtual void RunInternal() = 0; |
| 30 |
| 31 protected: |
| 32 Isolate* isolate_; |
| 33 |
| 34 private: |
| 35 bool is_cancelled_; |
| 36 |
| 37 DISALLOW_COPY_AND_ASSIGN(CancelableTask); |
| 38 }; |
| 39 |
| 40 } // namespace internal |
| 41 } // namespace v8 |
| 42 |
| 43 #endif // V8_CANCELABLE_TASK_H_ |
OLD | NEW |