🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@nxtedition/shared

Package Overview
Dependencies
Maintainers
11
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nxtedition/shared - npm Package Compare versions

Comparing version
5.1.8
to
5.1.9
+22
-0
lib/index.d.ts

@@ -31,2 +31,13 @@ export interface BufferRegion {

get handle(): SharedHandle;
/**
* Whether the ring buffer's data region is backed by explicit huge pages
* (Linux 2 MiB hugetlb). False on non-Linux platforms and when the huge-page
* allocation failed and the allocator fell back to regular pages.
*/
get hugePages(): boolean;
/**
* Physical size in bytes of the ring buffer's data region (page-aligned,
* rounded up to a power of two by the native allocator).
*/
get size(): number;
constructor(handleOrSize: SharedHandle | number);

@@ -48,2 +59,13 @@ readSome(next: (data: BufferRegion) => void | boolean): number;

get handle(): SharedHandle;
/**
* Whether the ring buffer's data region is backed by explicit huge pages
* (Linux 2 MiB hugetlb). False on non-Linux platforms and when the huge-page
* allocation failed and the allocator fell back to regular pages.
*/
get hugePages(): boolean;
/**
* Physical size in bytes of the ring buffer's data region (page-aligned,
* rounded up to a power of two by the native allocator).
*/
get size(): number;
get maxMessageSize(): number;

@@ -50,0 +72,0 @@ constructor(handleOrSize: SharedHandle | number, { yield: onYield, logger }?: WriterOptions);

@@ -36,2 +36,3 @@ // By placing the read and write indices far apart (multiples of a common

@@ -131,2 +132,3 @@

#state
#size
#mask

@@ -152,2 +154,19 @@ #int32

/**
* Whether the ring buffer's data region is backed by explicit huge pages
* (Linux 2 MiB hugetlb). False on non-Linux platforms and when the huge-page
* allocation failed and the allocator fell back to regular pages.
*/
get hugePages() {
return native.ring_get_huge_pages(this.#handle)
}
/**
* Physical size in bytes of the ring buffer's data region (page-aligned,
* rounded up to a power of two by the native allocator).
*/
get size() {
return this.#size
}
constructor(handleOrSize ) {

@@ -169,2 +188,3 @@ this.#handle = typeof handleOrSize === 'number' ? alloc(handleOrSize) : handleOrSize

this.#state = new Int32Array(this.#handle)
this.#size = size
this.#mask = size - 1

@@ -297,2 +317,19 @@ this.#int32 = new Int32Array(dataBuffer)

/**
* Whether the ring buffer's data region is backed by explicit huge pages
* (Linux 2 MiB hugetlb). False on non-Linux platforms and when the huge-page
* allocation failed and the allocator fell back to regular pages.
*/
get hugePages() {
return native.ring_get_huge_pages(this.#handle)
}
/**
* Physical size in bytes of the ring buffer's data region (page-aligned,
* rounded up to a power of two by the native allocator).
*/
get size() {
return this.#size
}
get maxMessageSize() {

@@ -299,0 +336,0 @@ return this.#size - 8

+2
-2
{
"name": "@nxtedition/shared",
"description": "Cross-thread primitives for Node.js worker threads",
"version": "5.1.8",
"version": "5.1.9",
"type": "module",

@@ -49,3 +49,3 @@ "main": "lib/index.js",

},
"gitHead": "ae8f780ca3c218e59b0f261796c209ed0afc5477"
"gitHead": "3dc938697b62497f7fa7556237359769d9bc960d"
}

@@ -49,2 +49,3 @@ #ifdef __linux__

void *addr;
bool huge_pages;
HANDLE mapping;

@@ -132,2 +133,3 @@ };

rb->addr = addr;
rb->huge_pages = false;
rb->mapping = mapping;

@@ -211,2 +213,3 @@ return rb;

void *addr;
bool huge_pages;
};

@@ -276,2 +279,3 @@

rb->addr = addr;
rb->huge_pages = huge_pages;
return rb;

@@ -571,2 +575,29 @@ }

// ring_get_huge_pages(handle: SharedArrayBuffer): boolean
//
// Returns true if the ring buffer's data region was allocated using explicit
// huge pages (Linux MAP_HUGETLB | MAP_HUGE_2MB). Returns false on other
// platforms and when the huge-page allocation failed and the allocator fell
// back to regular pages (possibly with transparent huge page hints).
static napi_value ring_get_huge_pages(napi_env env, napi_callback_info info)
{
size_t argc = 1;
napi_value args[1];
napi_get_cb_info(env, info, &argc, args, NULL, NULL);
if (argc < 1)
{
napi_throw_type_error(env, NULL, "ring_get_huge_pages: expected 1 argument");
return NULL;
}
ring_buf_t *rb = rb_from_handle(env, args[0], "ring_get_huge_pages");
if (!rb)
return NULL;
napi_value result;
napi_get_boolean(env, rb->huge_pages, &result);
return result;
}
// ring_is_int32_lock_free(): boolean

@@ -602,2 +633,6 @@ //

napi_create_function(env, "ring_get_huge_pages", NAPI_AUTO_LENGTH, ring_get_huge_pages, NULL,
&fn);
napi_set_named_property(env, exports, "ring_get_huge_pages", fn);
sabreg_register(env, exports);

@@ -604,0 +639,0 @@

Sorry, the diff of this file is not supported yet