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

Unified Diff: src/cancelable-task.h

Issue 1258923010: Add CancelableIdleTask. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix override Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/cancelable-task.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/cancelable-task.h
diff --git a/src/cancelable-task.h b/src/cancelable-task.h
index 1a15e248efe8bf555b4f4e6db6e0ca73e7b1a76a..bae5b580cd2330897f0e9d5aa71d415cfecccd1d 100644
--- a/src/cancelable-task.h
+++ b/src/cancelable-task.h
@@ -13,13 +13,29 @@ namespace internal {
class Isolate;
-class CancelableTask : public Task {
+
+class Cancelable {
public:
- explicit CancelableTask(Isolate* isolate);
- ~CancelableTask() override;
+ explicit Cancelable(Isolate* isolate);
+ virtual ~Cancelable();
+
+ virtual void Cancel() { is_cancelled_ = true; }
+
+ protected:
+ Isolate* isolate_;
+ bool is_cancelled_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Cancelable);
+};
- void Cancel() { is_cancelled_ = true; }
+// Multiple inheritance can be used because Task is a pure interface.
+class CancelableTask : public Cancelable, public Task {
+ public:
+ explicit CancelableTask(Isolate* isolate) : Cancelable(isolate) {}
+
+ // Task overrides.
void Run() final {
if (!is_cancelled_) {
RunInternal();
@@ -28,15 +44,30 @@ class CancelableTask : public Task {
virtual void RunInternal() = 0;
- protected:
- Isolate* isolate_;
-
private:
- bool is_cancelled_;
-
DISALLOW_COPY_AND_ASSIGN(CancelableTask);
};
+
+// Multiple inheritance can be used because IdleTask is a pure interface.
+class CancelableIdleTask : public Cancelable, public IdleTask {
+ public:
+ explicit CancelableIdleTask(Isolate* isolate) : Cancelable(isolate) {}
+
+ // IdleTask overrides.
+ void Run(double deadline_in_seconds) final {
+ if (!is_cancelled_) {
+ RunInternal(deadline_in_seconds);
+ }
+ }
+
+ virtual void RunInternal(double deadline_in_seconds) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CancelableIdleTask);
+};
+
+
} // namespace internal
} // namespace v8
« no previous file with comments | « no previous file | src/cancelable-task.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698