mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
worker: add public method for marking objects as untransferable
We currently mark a number of `ArrayBuffer`s as not transferable, including the `Buffer` pool and ones with finalizers provided by C++ addons. There is no good reason to assume that userland code might not encounter similar problems, for example when doing `ArrayBuffer` pooling similar to ours. Therefore, provide an API that lets userland code also mark objects as not transferable. PR-URL: https://github.com/nodejs/node/pull/33979 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
This commit is contained in:
1 parent
ced68bfa3d
commit
4875a511ea
9 files changed
+118
-21
No files matched your search
+2
-2
@@ -419,7 +419,7 @@ MaybeLocal<Object> New(Environment* env,
|
||||
Local<ArrayBuffer> ab =
|
||||
CallbackInfo::CreateTrackedArrayBuffer(env, data, length, callback, hint);
|
||||
if (ab->SetPrivate(env->context(),
|
||||
env->arraybuffer_untransferable_private_symbol(),
|
||||
env->untransferable_object_private_symbol(),
|
||||
True(env->isolate())).IsNothing()) {
|
||||
return Local<Object>();
|
||||
}
|
||||
@@ -1179,7 +1179,7 @@ void Initialize(Local<Object> target,
|
||||
ArrayBuffer::New(env->isolate(), std::move(backing));
|
||||
array_buffer->SetPrivate(
|
||||
env->context(),
|
||||
env->arraybuffer_untransferable_private_symbol(),
|
||||
env->untransferable_object_private_symbol(),
|
||||
True(env->isolate())).Check();
|
||||
CHECK(target
|
||||
->Set(env->context(),
|
||||
|
||||
Reference in new issue
Block a user