mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
src: add way to get IsolateData and allocator from Environment
Add a way to get the current `IsolateData*` and, from it, the current Node.js `ArrayBufferAllocator` if there is one. This can be useful for re-using either one of these structures as an embedder. PR-URL: https://github.com/nodejs/node/pull/36441 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
658a266cd4
commit
577d228ca0
3 files changed
+13
No files matched your search
@@ -466,6 +466,14 @@ MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform() {
|
||||
return per_process::v8_platform.Platform();
|
||||
}
|
||||
|
||||
IsolateData* GetEnvironmentIsolateData(Environment* env) {
|
||||
return env->isolate_data();
|
||||
}
|
||||
|
||||
ArrayBufferAllocator* GetArrayBufferAllocator(IsolateData* isolate_data) {
|
||||
return isolate_data->node_allocator();
|
||||
}
|
||||
|
||||
MultiIsolatePlatform* GetMultiIsolatePlatform(Environment* env) {
|
||||
return GetMultiIsolatePlatform(env->isolate_data());
|
||||
}
|
||||
|
||||
@@ -500,6 +500,8 @@ NODE_EXTERN void DefaultProcessExitHandler(Environment* env, int exit_code);
|
||||
|
||||
// This may return nullptr if context is not associated with a Node instance.
|
||||
NODE_EXTERN Environment* GetCurrentEnvironment(v8::Local<v8::Context> context);
|
||||
NODE_EXTERN IsolateData* GetEnvironmentIsolateData(Environment* env);
|
||||
NODE_EXTERN ArrayBufferAllocator* GetArrayBufferAllocator(IsolateData* data);
|
||||
|
||||
NODE_EXTERN void OnFatalError(const char* location, const char* message);
|
||||
NODE_EXTERN void PromiseRejectCallback(v8::PromiseRejectMessage message);
|
||||
|
||||
@@ -627,6 +627,9 @@ TEST_F(NodeZeroIsolateTestFixture, CtrlCWithOnlySafeTerminationTest) {
|
||||
{}),
|
||||
node::FreeEnvironment};
|
||||
CHECK(environment);
|
||||
EXPECT_EQ(node::GetEnvironmentIsolateData(environment.get()),
|
||||
isolate_data.get());
|
||||
EXPECT_EQ(node::GetArrayBufferAllocator(isolate_data.get()), nullptr);
|
||||
|
||||
v8::Local<v8::Value> main_ret =
|
||||
node::LoadEnvironment(environment.get(),
|
||||
|
||||
Reference in new issue
Block a user