summaryrefslogtreecommitdiff
path: root/deps
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2017-11-19 14:35:59 +0100
committerMichaƫl Zasso <targos@protonmail.com>2017-12-06 12:52:07 +0100
commit99ac5cdf90163c11508b15a608c8496fa6dbe49c (patch)
treed29eaca9462d8f123c3d44af07d1e7d276d120de /deps
parente01a210c7f40f7cffe2db608707f717fb3cb5e29 (diff)
downloadandroid-node-v8-99ac5cdf90163c11508b15a608c8496fa6dbe49c.tar.gz
android-node-v8-99ac5cdf90163c11508b15a608c8496fa6dbe49c.tar.bz2
android-node-v8-99ac5cdf90163c11508b15a608c8496fa6dbe49c.zip
deps: cherry-pick c690f54d95802 from V8 upstream
Original commit message: [platform] Add TaskRunner to the platform API With the existing platform API it is not possible to post foreground tasks from background tasks. This is, however, required to implement asynchronous compilation for WebAssembly. With this CL we add the concept of a TaskRunner to the platform API. The TaskRunner contains all data needed to post a foreground task and can be used both from a foreground task and a background task. Eventually the TaskRunner should replace the existing API. In addition, this CL contains a default implementation of the TaskRunner. This implementation has tempory workaround for platforms which do not provide a TaskRunner implementation yet. This default implementation should be deleted again when all platforms provide a TaskRunner implementation. R=rmcilroy@chromium.org Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: I6ea4a1c9da1eb9a19e8ce8f2163000dbc2598802 Reviewed-on: https://chromium-review.googlesource.com/741588 Commit-Queue: Andreas Haas <ahaas@chromium.org> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Cr-Commit-Position: refs/heads/master@{#49041} Refs: https://github.com/v8/v8/commit/c690f54d9580243c53f7d892fcff1ce6bae4bfc0 PR-URL: https://github.com/nodejs/node/pull/17134 Fixes: https://github.com/nodejs/node-v8/issues/24 Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'deps')
-rw-r--r--deps/v8/include/v8-platform.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/deps/v8/include/v8-platform.h b/deps/v8/include/v8-platform.h
index 74630b6f19..932a36ae7d 100644
--- a/deps/v8/include/v8-platform.h
+++ b/deps/v8/include/v8-platform.h
@@ -37,6 +37,51 @@ class IdleTask {
};
/**
+ * A TaskRunner allows scheduling of tasks. The TaskRunner may still be used to
+ * post tasks after the isolate gets destructed, but these tasks may not get
+ * executed anymore. All tasks posted to a given TaskRunner will be invoked in
+ * sequence. Tasks can be posted from any thread.
+ */
+class TaskRunner {
+ public:
+ /**
+ * Schedules a task to be invoked by this TaskRunner. The TaskRunner
+ * implementation takes ownership of |task|.
+ */
+ virtual void PostTask(std::unique_ptr<Task> task) = 0;
+
+ /**
+ * Schedules a task to be invoked by this TaskRunner. The task is scheduled
+ * after the given number of seconds |delay_in_seconds|. The TaskRunner
+ * implementation takes ownership of |task|.
+ */
+ virtual void PostDelayedTask(std::unique_ptr<Task> task,
+ double delay_in_seconds) = 0;
+
+ /**
+ * Schedules an idle task to be invoked by this TaskRunner. The task is
+ * scheduled when the embedder is idle. Requires that
+ * TaskRunner::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 TaskRunner implementation takes
+ * ownership of |task|.
+ */
+ virtual void PostIdleTask(std::unique_ptr<IdleTask> task) = 0;
+
+ /**
+ * Returns true if idle tasks are enabled for this TaskRunner.
+ */
+ virtual bool IdleTasksEnabled() = 0;
+
+ TaskRunner() = default;
+ virtual ~TaskRunner() = default;
+
+ private:
+ TaskRunner(const TaskRunner&) = delete;
+ TaskRunner& operator=(const TaskRunner&) = delete;
+};
+
+/**
* The interface represents complex arguments to trace events.
*/
class ConvertableToTraceFormat {
@@ -151,6 +196,28 @@ class Platform {
virtual size_t NumberOfAvailableBackgroundThreads() { return 0; }
/**
+ * Returns a TaskRunner which can be used to post a task on the foreground.
+ * This function should only be called from a foreground thread.
+ */
+ virtual std::unique_ptr<v8::TaskRunner> GetForegroundTaskRunner(
+ Isolate* isolate) {
+ // TODO(ahaas): Make this function abstract after it got implemented on all
+ // platforms.
+ return {};
+ }
+
+ /**
+ * Returns a TaskRunner which can be used to post a task on a background.
+ * This function should only be called from a foreground thread.
+ */
+ virtual std::unique_ptr<v8::TaskRunner> GetBackgroundTaskRunner(
+ Isolate* isolate) {
+ // TODO(ahaas): Make this function abstract after it got implemented on all
+ // platforms.
+ return {};
+ }
+
+ /**
* Schedules a task to be invoked on a background thread. |expected_runtime|
* indicates that the task will run a long time. The Platform implementation
* takes ownership of |task|. There is no guarantee about order of execution