| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2e31126 commit 7812c93
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,6 +36,51 @@ class IdleTask { | |||
| 36 | 36 | virtual void Run(double deadline_in_seconds) = 0; | |
| 37 | 37 | }; | |
| 38 | 38 | ||
| 39 | + /** | ||
| 40 | + * A TaskRunner allows scheduling of tasks. The TaskRunner may still be used to | ||
| 41 | + * post tasks after the isolate gets destructed, but these tasks may not get | ||
| 42 | + * executed anymore. All tasks posted to a given TaskRunner will be invoked in | ||
| 43 | + * sequence. Tasks can be posted from any thread. | ||
| 44 | + */ | ||
| 45 | + class TaskRunner { | ||
| 46 | + public: | ||
| 47 | + /** | ||
| 48 | + * Schedules a task to be invoked by this TaskRunner. The TaskRunner | ||
| 49 | + * implementation takes ownership of |task|. | ||
| 50 | + */ | ||
| 51 | + virtual void PostTask(std::unique_ptr<Task> task) = 0; | ||
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * Schedules a task to be invoked by this TaskRunner. The task is scheduled | ||
| 55 | + * after the given number of seconds |delay_in_seconds|. The TaskRunner | ||
| 56 | + * implementation takes ownership of |task|. | ||
| 57 | + */ | ||
| 58 | + virtual void PostDelayedTask(std::unique_ptr<Task> task, | ||
| 59 | + double delay_in_seconds) = 0; | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * Schedules an idle task to be invoked by this TaskRunner. The task is | ||
| 63 | + * scheduled when the embedder is idle. Requires that | ||
| 64 | + * TaskRunner::SupportsIdleTasks(isolate) is true. Idle tasks may be reordered | ||
| 65 | + * relative to other task types and may be starved for an arbitrarily long | ||
| 66 | + * time if no idle time is available. The TaskRunner implementation takes | ||
| 67 | + * ownership of |task|. | ||
| 68 | + */ | ||
| 69 | + virtual void PostIdleTask(std::unique_ptr<IdleTask> task) = 0; | ||
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * Returns true if idle tasks are enabled for this TaskRunner. | ||
| 73 | + */ | ||
| 74 | + virtual bool IdleTasksEnabled() = 0; | ||
| 75 | + | ||
| 76 | + TaskRunner() = default; | ||
| 77 | + virtual ~TaskRunner() = default; | ||
| 78 | + | ||
| 79 | + private: | ||
| 80 | + TaskRunner(const TaskRunner&) = delete; | ||
| 81 | + TaskRunner& operator=(const TaskRunner&) = delete; | ||
| 82 | + }; | ||
| 83 | + | ||
| 39 | 84 | /** | |
| 40 | 85 | * The interface represents complex arguments to trace events. | |
| 41 | 86 | */ | |
@@ -150,6 +195,28 @@ class Platform { | |||
| 150 | 195 | */ | |
| 151 | 196 | virtual size_t NumberOfAvailableBackgroundThreads() { return 0; } | |
| 152 | 197 | ||
| 198 | + /** | ||
| 199 | + * Returns a TaskRunner which can be used to post a task on the foreground. | ||
| 200 | + * This function should only be called from a foreground thread. | ||
| 201 | + */ | ||
| 202 | + virtual std::unique_ptr<v8::TaskRunner> GetForegroundTaskRunner( | ||
| 203 | + Isolate* isolate) { | ||
| 204 | + // TODO(ahaas): Make this function abstract after it got implemented on all | ||
| 205 | + // platforms. | ||
| 206 | + return {}; | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + /** | ||
| 210 | + * Returns a TaskRunner which can be used to post a task on a background. | ||
| 211 | + * This function should only be called from a foreground thread. | ||
| 212 | + */ | ||
| 213 | + virtual std::unique_ptr<v8::TaskRunner> GetBackgroundTaskRunner( | ||
| 214 | + Isolate* isolate) { | ||
| 215 | + // TODO(ahaas): Make this function abstract after it got implemented on all | ||
| 216 | + // platforms. | ||
| 217 | + return {}; | ||
| 218 | + } | ||
| 219 | + | ||
| 153 | 220 | /** | |
| 154 | 221 | * Schedules a task to be invoked on a background thread. |expected_runtime| | |
| 155 | 222 | * indicates that the task will run a long time. The Platform implementation | |
| Back | FazBrowse Home | New Git URL |
0 commit comments