From b0404047c1e4f7652aaf6ecf911d5850d5acf570 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 13 May 2018 19:39:32 +0200 Subject: worker: add `SharedArrayBuffer` sharing Logic is added to the `MessagePort` mechanism that attaches hidden objects to those instances when they are transferred that track their lifetime and maintain a reference count, to make sure that memory is freed at the appropriate times. Thanks to Stephen Belanger for reviewing this change in its original PR. Refs: https://github.com/ayojs/ayo/pull/106 PR-URL: https://github.com/nodejs/node/pull/20876 Reviewed-By: Gireesh Punathil Reviewed-By: Benjamin Gruenbaum Reviewed-By: Shingo Inoue Reviewed-By: Matteo Collina Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: John-David Dalton Reviewed-By: Gus Caplan --- src/node_messaging.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/node_messaging.h') diff --git a/src/node_messaging.h b/src/node_messaging.h index 074267bb67..ff8fcc7243 100644 --- a/src/node_messaging.h +++ b/src/node_messaging.h @@ -5,8 +5,8 @@ #include "env.h" #include "node_mutex.h" +#include "sharedarraybuffer_metadata.h" #include -#include namespace node { namespace worker { @@ -37,6 +37,9 @@ class Message { v8::Local input, v8::Local transfer_list); + // Internal method of Message that is called when a new SharedArrayBuffer + // object is encountered in the incoming value's structure. + void AddSharedArrayBuffer(SharedArrayBufferMetadataReference ref); // Internal method of Message that is called once serialization finishes // and that transfers ownership of `data` to this message. void AddMessagePort(std::unique_ptr&& data); @@ -44,6 +47,7 @@ class Message { private: MallocedBuffer main_message_buf_; std::vector> array_buffer_contents_; + std::vector shared_array_buffers_; std::vector> message_ports_; friend class MessagePort; -- cgit v1.2.3