| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b7bcf3e commit 525b3f2
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -245,11 +245,13 @@ void PerIsolatePlatformData::FlushTasks(uv_async_t* handle) { | |||
| 245 | 245 | platform_data->FlushForegroundTasksInternal(); | |
| 246 | 246 | } | |
| 247 | 247 | ||
| 248 | - void PerIsolatePlatformData::PostIdleTask(std::unique_ptr<v8::IdleTask> task) { | ||
| 248 | + void PerIsolatePlatformData::PostIdleTaskImpl( | ||
| 249 | + std::unique_ptr<v8::IdleTask> task, const v8::SourceLocation& location) { | ||
| 249 | 250 | UNREACHABLE(); | |
| 250 | 251 | } | |
| 251 | 252 | ||
| 252 | - void PerIsolatePlatformData::PostTask(std::unique_ptr<Task> task) { | ||
| 253 | + void PerIsolatePlatformData::PostTaskImpl(std::unique_ptr<Task> task, | ||
| 254 | + const v8::SourceLocation& location) { | ||
| 253 | 255 | if (flush_tasks_ == nullptr) { | |
| 254 | 256 | // V8 may post tasks during Isolate disposal. In that case, the only | |
| 255 | 257 | // sensible path forward is to discard the task. | |
@@ -259,8 +261,10 @@ void PerIsolatePlatformData::PostTask(std::unique_ptr<Task> task) { | |||
| 259 | 261 | uv_async_send(flush_tasks_); | |
| 260 | 262 | } | |
| 261 | 263 | ||
| 262 | - void PerIsolatePlatformData::PostDelayedTask( | ||
| 263 | - std::unique_ptr<Task> task, double delay_in_seconds) { | ||
| 264 | + void PerIsolatePlatformData::PostDelayedTaskImpl( | ||
| 265 | + std::unique_ptr<Task> task, | ||
| 266 | + double delay_in_seconds, | ||
| 267 | + const v8::SourceLocation& location) { | ||
| 264 | 268 | if (flush_tasks_ == nullptr) { | |
| 265 | 269 | // V8 may post tasks during Isolate disposal. In that case, the only | |
| 266 | 270 | // sensible path forward is to discard the task. | |
@@ -274,14 +278,16 @@ void PerIsolatePlatformData::PostDelayedTask( | |||
| 274 | 278 | uv_async_send(flush_tasks_); | |
| 275 | 279 | } | |
| 276 | 280 | ||
| 277 | - void PerIsolatePlatformData::PostNonNestableTask(std::unique_ptr<Task> task) { | ||
| 278 | - PostTask(std::move(task)); | ||
| 281 | + void PerIsolatePlatformData::PostNonNestableTaskImpl( | ||
| 282 | + std::unique_ptr<Task> task, const v8::SourceLocation& location) { | ||
| 283 | + PostTaskImpl(std::move(task), location); | ||
| 279 | 284 | } | |
| 280 | 285 | ||
| 281 | - void PerIsolatePlatformData::PostNonNestableDelayedTask( | ||
| 286 | + void PerIsolatePlatformData::PostNonNestableDelayedTaskImpl( | ||
| 282 | 287 | std::unique_ptr<Task> task, | |
| 283 | - double delay_in_seconds) { | ||
| 284 | - PostDelayedTask(std::move(task), delay_in_seconds); | ||
| 288 | + double delay_in_seconds, | ||
| 289 | + const v8::SourceLocation& location) { | ||
| 290 | + PostDelayedTaskImpl(std::move(task), delay_in_seconds, location); | ||
| 285 | 291 | } | |
| 286 | 292 | ||
| 287 | 293 | PerIsolatePlatformData::~PerIsolatePlatformData() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,10 +3,10 @@ | |||
| 3 | 3 | ||
| 4 | 4 | #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | |
| 5 | 5 | ||
| 6 | + #include <functional> | ||
| 6 | 7 | #include <queue> | |
| 7 | 8 | #include <unordered_map> | |
| 8 | 9 | #include <vector> | |
| 9 | - #include <functional> | ||
| 10 | 10 | ||
| 11 | 11 | #include "libplatform/libplatform.h" | |
| 12 | 12 | #include "node.h" | |
@@ -50,27 +50,20 @@ struct DelayedTask { | |||
| 50 | 50 | }; | |
| 51 | 51 | ||
| 52 | 52 | // This acts as the foreground task runner for a given Isolate. | |
| 53 | - class PerIsolatePlatformData : | ||
| 54 | - public IsolatePlatformDelegate, | ||
| 55 | - public v8::TaskRunner, | ||
| 56 | - public std::enable_shared_from_this<PerIsolatePlatformData> { | ||
| 53 | + class PerIsolatePlatformData | ||
| 54 | + : public IsolatePlatformDelegate, | ||
| 55 | + public v8::TaskRunner, | ||
| 56 | + public std::enable_shared_from_this<PerIsolatePlatformData> { | ||
| 57 | 57 | public: | |
| 58 | 58 | PerIsolatePlatformData(v8::Isolate* isolate, uv_loop_t* loop); | |
| 59 | 59 | ~PerIsolatePlatformData() override; | |
| 60 | 60 | ||
| 61 | 61 | std::shared_ptr<v8::TaskRunner> GetForegroundTaskRunner() override; | |
| 62 | - void PostTask(std::unique_ptr<v8::Task> task) override; | ||
| 63 | - void PostIdleTask(std::unique_ptr<v8::IdleTask> task) override; | ||
| 64 | - void PostDelayedTask(std::unique_ptr<v8::Task> task, | ||
| 65 | - double delay_in_seconds) override; | ||
| 66 | 62 | bool IdleTasksEnabled() override { return false; } | |
| 67 | 63 | ||
| 68 | 64 | // Non-nestable tasks are treated like regular tasks. | |
| 69 | 65 | bool NonNestableTasksEnabled() const override { return true; } | |
| 70 | 66 | bool NonNestableDelayedTasksEnabled() const override { return true; } | |
| 71 | - void PostNonNestableTask(std::unique_ptr<v8::Task> task) override; | ||
| 72 | - void PostNonNestableDelayedTask(std::unique_ptr<v8::Task> task, | ||
| 73 | - double delay_in_seconds) override; | ||
| 74 | 67 | ||
| 75 | 68 | void AddShutdownCallback(void (*callback)(void*), void* data); | |
| 76 | 69 | void Shutdown(); | |
@@ -83,6 +76,21 @@ class PerIsolatePlatformData : | |||
| 83 | 76 | const uv_loop_t* event_loop() const { return loop_; } | |
| 84 | 77 | ||
| 85 | 78 | private: | |
| 79 | + // v8::TaskRunner implementation. | ||
| 80 | + void PostTaskImpl(std::unique_ptr<v8::Task> task, | ||
| 81 | + const v8::SourceLocation& location) override; | ||
| 82 | + void PostDelayedTaskImpl(std::unique_ptr<v8::Task> task, | ||
| 83 | + double delay_in_seconds, | ||
| 84 | + const v8::SourceLocation& location) override; | ||
| 85 | + void PostIdleTaskImpl(std::unique_ptr<v8::IdleTask> task, | ||
| 86 | + const v8::SourceLocation& location) override; | ||
| 87 | + void PostNonNestableTaskImpl(std::unique_ptr<v8::Task> task, | ||
| 88 | + const v8::SourceLocation& location) override; | ||
| 89 | + void PostNonNestableDelayedTaskImpl( | ||
| 90 | + std::unique_ptr<v8::Task> task, | ||
| 91 | + double delay_in_seconds, | ||
| 92 | + const v8::SourceLocation& location) override; | ||
| 93 | + | ||
| 86 | 94 | void DeleteFromScheduledTasks(DelayedTask* task); | |
| 87 | 95 | void DecreaseHandleCount(); | |
| 88 | 96 | ||
@@ -107,7 +115,7 @@ class PerIsolatePlatformData : | |||
| 107 | 115 | TaskQueue<DelayedTask> foreground_delayed_tasks_; | |
| 108 | 116 | ||
| 109 | 117 | // Use a custom deleter because libuv needs to close the handle first. | |
| 110 | - typedef std::unique_ptr<DelayedTask, void(*)(DelayedTask*)> | ||
| 118 | + typedef std::unique_ptr<DelayedTask, void (*)(DelayedTask*)> | ||
| 111 | 119 | DelayedTaskPointer; | |
| 112 | 120 | std::vector<DelayedTaskPointer> scheduled_delayed_tasks_; | |
| 113 | 121 | }; | |
@@ -118,8 +126,7 @@ class WorkerThreadsTaskRunner { | |||
| 118 | 126 | explicit WorkerThreadsTaskRunner(int thread_pool_size); | |
| 119 | 127 | ||
| 120 | 128 | void PostTask(std::unique_ptr<v8::Task> task); | |
| 121 | - void PostDelayedTask(std::unique_ptr<v8::Task> task, | ||
| 122 | - double delay_in_seconds); | ||
| 129 | + void PostDelayedTask(std::unique_ptr<v8::Task> task, double delay_in_seconds); | ||
| 123 | 130 | ||
| 124 | 131 | void BlockingDrain(); | |
| 125 | 132 | void Shutdown(); | |
@@ -171,7 +178,8 @@ class NodePlatform : public MultiIsolatePlatform { | |||
| 171 | 178 | ||
| 172 | 179 | void UnregisterIsolate(v8::Isolate* isolate) override; | |
| 173 | 180 | void AddIsolateFinishedCallback(v8::Isolate* isolate, | |
| 174 | - void (*callback)(void*), void* data) override; | ||
| 181 | + void (*callback)(void*), | ||
| 182 | + void* data) override; | ||
| 175 | 183 | ||
| 176 | 184 | std::shared_ptr<v8::TaskRunner> GetForegroundTaskRunner( | |
| 177 | 185 | v8::Isolate* isolate) override; | |
@@ -184,8 +192,8 @@ class NodePlatform : public MultiIsolatePlatform { | |||
| 184 | 192 | std::shared_ptr<PerIsolatePlatformData> ForNodeIsolate(v8::Isolate* isolate); | |
| 185 | 193 | ||
| 186 | 194 | Mutex per_isolate_mutex_; | |
| 187 | - using DelegatePair = std::pair< | ||
| 188 | - IsolatePlatformDelegate*, std::shared_ptr<PerIsolatePlatformData>>; | ||
| 195 | + using DelegatePair = std::pair<IsolatePlatformDelegate*, | ||
| 196 | + std::shared_ptr<PerIsolatePlatformData>>; | ||
| 189 | 197 | std::unordered_map<v8::Isolate*, DelegatePair> per_isolate_; | |
| 190 | 198 | ||
| 191 | 199 | v8::TracingController* tracing_controller_; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments