Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/d8/d8-platforms.cc')
-rw-r--r--deps/v8/src/d8/d8-platforms.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/deps/v8/src/d8/d8-platforms.cc b/deps/v8/src/d8/d8-platforms.cc
index 48ea3c94814..5ea43b14760 100644
--- a/deps/v8/src/d8/d8-platforms.cc
+++ b/deps/v8/src/d8/d8-platforms.cc
@@ -43,9 +43,17 @@ class PredictablePlatform : public Platform {
int NumberOfWorkerThreads() override { return 0; }
void CallOnWorkerThread(std::unique_ptr<Task> task) override {
- // It's not defined when background tasks are being executed, so we can just
- // execute them right away.
- task->Run();
+ // We post worker tasks on the foreground task runner of the
+ // {kProcessGlobalPredictablePlatformWorkerTaskQueue} isolate. The task
+ // queue of the {kProcessGlobalPredictablePlatformWorkerTaskQueue} isolate
+ // is then executed on the main thread to achieve predictable behavior.
+ //
+ // In this context here it is okay to call {GetForegroundTaskRunner} from a
+ // background thread. The reason is that code is executed sequentially with
+ // the PredictablePlatform, and that the {DefaultPlatform} does not access
+ // the isolate but only uses it as the key in a HashMap.
+ GetForegroundTaskRunner(kProcessGlobalPredictablePlatformWorkerTaskQueue)
+ ->PostTask(std::move(task));
}
void CallDelayedOnWorkerThread(std::unique_ptr<Task> task,