Index: src/cancelable-task.h |
diff --git a/src/cancelable-task.h b/src/cancelable-task.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1a15e248efe8bf555b4f4e6db6e0ca73e7b1a76a |
--- /dev/null |
+++ b/src/cancelable-task.h |
@@ -0,0 +1,43 @@ |
+// Copyright 2015 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef V8_CANCELABLE_TASK_H_ |
+#define V8_CANCELABLE_TASK_H_ |
+ |
+#include "include/v8-platform.h" |
+#include "src/base/macros.h" |
+ |
+namespace v8 { |
+namespace internal { |
+ |
+class Isolate; |
+ |
+class CancelableTask : public Task { |
+ public: |
+ explicit CancelableTask(Isolate* isolate); |
+ ~CancelableTask() override; |
+ |
+ void Cancel() { is_cancelled_ = true; } |
+ |
+ void Run() final { |
+ if (!is_cancelled_) { |
+ RunInternal(); |
+ } |
+ } |
+ |
+ virtual void RunInternal() = 0; |
+ |
+ protected: |
+ Isolate* isolate_; |
+ |
+ private: |
+ bool is_cancelled_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CancelableTask); |
+}; |
+ |
+} // namespace internal |
+} // namespace v8 |
+ |
+#endif // V8_CANCELABLE_TASK_H_ |