The C and C++ Include Header Files
/usr/include/nodejs/src/sharedarraybuffer_metadata.h
$ cat -n /usr/include/nodejs/src/sharedarraybuffer_metadata.h 1 #ifndef SRC_SHAREDARRAYBUFFER_METADATA_H_ 2 #define SRC_SHAREDARRAYBUFFER_METADATA_H_ 3 4 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 5 6 #include "node.h" 7 #include
8 9 namespace node { 10 namespace worker { 11 12 class SharedArrayBufferMetadata; 13 14 // This is an object associated with a SharedArrayBuffer, which keeps track 15 // of a cross-thread reference count. Once a SharedArrayBuffer is transferred 16 // for the first time (or is attempted to be transferred), one of these objects 17 // is created, and the SharedArrayBuffer is moved from internalized mode into 18 // externalized mode (i.e. the JS engine no longer frees the memory on its own). 19 // 20 // This will always be referred to using a std::shared_ptr, since it keeps 21 // a reference count and is guaranteed to be thread-safe. 22 typedef std::shared_ptr
23 SharedArrayBufferMetadataReference; 24 25 class SharedArrayBufferMetadata 26 : public std::enable_shared_from_this
{ 27 public: 28 static SharedArrayBufferMetadataReference ForSharedArrayBuffer( 29 Environment* env, 30 v8::Local
context, 31 v8::Local
source); 32 ~SharedArrayBufferMetadata(); 33 34 // Create a SharedArrayBuffer object for a specific Environment and Context. 35 // The created SharedArrayBuffer will be in externalized mode and has 36 // a hidden object attached to it, during whose lifetime the reference 37 // count is increased by 1. 38 v8::MaybeLocal
GetSharedArrayBuffer( 39 Environment* env, v8::Local
context); 40 std::shared_ptr
allocator() const { 41 return allocator_; 42 } 43 44 SharedArrayBufferMetadata(SharedArrayBufferMetadata&& other) = delete; 45 SharedArrayBufferMetadata& operator=( 46 SharedArrayBufferMetadata&& other) = delete; 47 SharedArrayBufferMetadata& operator=( 48 const SharedArrayBufferMetadata&) = delete; 49 SharedArrayBufferMetadata(const SharedArrayBufferMetadata&) = delete; 50 51 private: 52 SharedArrayBufferMetadata( 53 const v8::SharedArrayBuffer::Contents&, 54 std::shared_ptr
); 55 56 // Attach a lifetime tracker object with a reference count to `target`. 57 v8::Maybe
AssignToSharedArrayBuffer( 58 Environment* env, 59 v8::Local
context, 60 v8::Local
target); 61 62 v8::SharedArrayBuffer::Contents contents_; 63 std::shared_ptr
allocator_; 64 }; 65 66 } // namespace worker 67 } // namespace node 68 69 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 70 71 72 #endif // SRC_SHAREDARRAYBUFFER_METADATA_H_
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2024 MyWebUniversity.com ™