diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-11-13 19:19:54 +0000 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-11-19 14:01:32 +0100 |
commit | 6cb8e4b12cd16ae8ed126f98458efb78312cabf6 (patch) | |
tree | e37ef2d4f2104f6f51479ea78c63e6f890cea7c0 /src/node_api.cc | |
parent | 1317ac65b4f001588b86002aa22431719683beb4 (diff) | |
download | android-node-v8-6cb8e4b12cd16ae8ed126f98458efb78312cabf6.tar.gz android-node-v8-6cb8e4b12cd16ae8ed126f98458efb78312cabf6.tar.bz2 android-node-v8-6cb8e4b12cd16ae8ed126f98458efb78312cabf6.zip |
src: mark ArrayBuffers with free callbacks as untransferable
More precisely, make them untransferable if they were created through
*our* APIs, because those do not follow the improved free callback
mechanism that V8 uses now. All other ArrayBuffers can be transferred
between threads now, the assumption being that they were created in a
clean way that follows the V8 API on this.
This addresses a TODO comment.
Refs: https://github.com/nodejs/node/pull/30339#issuecomment-552225353
PR-URL: https://github.com/nodejs/node/pull/30475
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Diffstat (limited to 'src/node_api.cc')
-rw-r--r-- | src/node_api.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/node_api.cc b/src/node_api.cc index 95664e9c7a..b293272b91 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -24,6 +24,14 @@ struct node_napi_env__ : public napi_env__ { bool can_call_into_js() const override { return node_env()->can_call_into_js(); } + + v8::Maybe<bool> mark_arraybuffer_as_untransferable( + v8::Local<v8::ArrayBuffer> ab) const { + return ab->SetPrivate( + context(), + node_env()->arraybuffer_untransferable_private_symbol(), + v8::True(isolate)); + } }; typedef node_napi_env__* node_napi_env; |