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_;
0 commit comments