-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement IsolatePlatformDelegate API
This is the solution for the issue raised in #132 and discussed in #133. Implements the API which landed in nodejs c712fb7c. We should be able to take advantage of this starting in nodejs 14.x
- Loading branch information
Showing
10 changed files
with
297 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include "platform_delegate.h" | ||
|
||
namespace ivm { | ||
namespace { | ||
PlatformDelegate delegate; | ||
} | ||
#if IVM_USE_PLATFORM_DELEGATE_HACK | ||
|
||
void PlatformDelegate::InitializeDelegate() { | ||
auto node_platform = reinterpret_cast<node::MultiIsolatePlatform*>(v8::internal::V8::GetCurrentPlatform()); | ||
delegate = PlatformDelegate{node_platform}; | ||
v8::V8::ShutdownPlatform(); | ||
v8::V8::InitializePlatform(&delegate); | ||
} | ||
|
||
void PlatformDelegate::RegisterIsolate(v8::Isolate* isolate, IsolatePlatformDelegate* isolate_delegate) { | ||
auto result = delegate.isolate_map.write()->insert(std::make_pair(isolate, isolate_delegate)); | ||
assert(result.second); | ||
} | ||
|
||
void PlatformDelegate::UnregisterIsolate(v8::Isolate* isolate) { | ||
auto result = delegate.isolate_map.write()->erase(isolate); | ||
assert(result == 1); | ||
} | ||
|
||
#else | ||
|
||
void PlatformDelegate::InitializeDelegate() { | ||
auto node_platform = node::GetMainThreadMultiIsolatePlatform(); | ||
delegate = PlatformDelegate{node_platform}; | ||
} | ||
|
||
void PlatformDelegate::RegisterIsolate(v8::Isolate* isolate, IsolatePlatformDelegate* isolate_delegate) { | ||
delegate.node_platform->RegisterIsolate(isolate, isolate_delegate); | ||
} | ||
|
||
void PlatformDelegate::UnregisterIsolate(v8::Isolate* isolate) { | ||
delegate.node_platform->UnregisterIsolate(isolate); | ||
} | ||
|
||
#endif | ||
|
||
} // namespace ivm |
Oops, something went wrong.