-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
src: clean up MultiIsolatePlatform interface #26384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Since this was introduced, V8 has effectively started requiring that the platform knows of the `Isolate*` before we (or an embedder) create our `IsolateData` structure; therefore, (un)registering it from the `IsolateData` constructor/destructor doesn’t make much sense anymore. - Instead, we can require that the register/unregister functions are only called once, simplifying the implementation a bit. - Add a callback that we can use to know when the platform has cleaned up its resources associated with a given `Isolate`. In particular, this means that in the Worker code, we don’t need to rely on what are essentially guesses about the number of event loop turns that we need in order to have everything cleaned up.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,11 +64,9 @@ class PerIsolatePlatformData : | |
| double delay_in_seconds) override; | ||
| bool IdleTasksEnabled() override { return false; } | ||
|
|
||
| void AddShutdownCallback(void (*callback)(void*), void* data); | ||
| void Shutdown(); | ||
|
|
||
| void ref(); | ||
| int unref(); | ||
|
|
||
| // Returns true if work was dispatched or executed. New tasks that are | ||
| // posted during flushing of the queue are postponed until the next | ||
| // flushing. | ||
|
|
@@ -84,7 +82,13 @@ class PerIsolatePlatformData : | |
| static void RunForegroundTask(std::unique_ptr<v8::Task> task); | ||
| static void RunForegroundTask(uv_timer_t* timer); | ||
|
|
||
| int ref_count_ = 1; | ||
| struct ShutdownCallback { | ||
| void (*cb)(void*); | ||
| void* data; | ||
| }; | ||
| typedef std::vector<ShutdownCallback> ShutdownCbList; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I remember we usually use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uh… is there any reason for that? Unless we need referential integrity or expect a lot of overhead from copying large entries, In any case, the expected length of the |
||
| ShutdownCbList shutdown_callbacks_; | ||
|
|
||
| uv_loop_t* const loop_; | ||
| uv_async_t* flush_tasks_ = nullptr; | ||
| TaskQueue<v8::Task> foreground_tasks_; | ||
|
|
@@ -145,6 +149,8 @@ class NodePlatform : public MultiIsolatePlatform { | |
|
|
||
| void RegisterIsolate(v8::Isolate* isolate, uv_loop_t* loop) override; | ||
| void UnregisterIsolate(v8::Isolate* isolate) override; | ||
| void AddIsolateFinishedCallback(v8::Isolate* isolate, | ||
| void (*callback)(void*), void* data) override; | ||
|
|
||
| std::shared_ptr<v8::TaskRunner> GetForegroundTaskRunner( | ||
| v8::Isolate* isolate) override; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.