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

Unified Diff: include/v8-platform.h

Issue 1225713003: Add IdleTask API to v8::Platform. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/libplatform/default-platform.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8-platform.h
diff --git a/include/v8-platform.h b/include/v8-platform.h
index be9e5c0c6b46ed122de88253e96f0cbaf8a0d98a..c6cba0f982929aa8795e214c89f9fc1adc4ffb11 100644
--- a/include/v8-platform.h
+++ b/include/v8-platform.h
@@ -19,6 +19,20 @@ class Task {
virtual void Run() = 0;
};
+
+/**
+* An IdleTask represents a unit of work to be performed in idle time.
+* The Run method is invoked with an argument that specifies the deadline in
+* seconds returned by MonotonicallyIncreasingTime().
+* The idle task is expected to complete by this deadline.
+*/
+class IdleTask {
+ public:
+ virtual ~IdleTask() {}
+ virtual void Run(double deadline_in_seconds) = 0;
+};
+
+
/**
* V8 Platform abstraction layer.
*
@@ -63,8 +77,26 @@ class Platform {
* scheduling. The definition of "foreground" is opaque to V8.
*/
virtual void CallDelayedOnForegroundThread(Isolate* isolate, Task* task,
- double delay_in_seconds) {
+ double delay_in_seconds) = 0;
+
+ /**
+ * Schedules a task to be invoked on a foreground thread wrt a specific
+ * |isolate| when the embedder is idle.
+ * Requires that SupportsIdleTasks(isolate) is true.
+ * Idle tasks may be reordered relative to other task types and may be
+ * starved for an arbitrarily long time if no idle time is available.
+ * The definition of "foreground" is opaque to V8.
+ */
+ virtual void CallIdleOnForegroundThread(Isolate* isolate, IdleTask* task) {
+ // TODO(ulan): Make this function abstract after V8 roll in Chromium.
+ }
+
+ /**
+ * Returns true if idle tasks are enabled for the given |isolate|.
+ */
+ virtual bool IdleTasksEnabled(Isolate* isolate) {
// TODO(ulan): Make this function abstract after V8 roll in Chromium.
+ return false;
}
/**
« no previous file with comments | « no previous file | src/libplatform/default-platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698