Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

piscina

Package Overview
Dependencies
Maintainers
3
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

piscina - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

test/fixtures/send-buffer-then-get-length.js

4

dist/package.json
{
"name": "piscina",
"version": "3.1.0",
"version": "3.2.0",
"description": "A fast, efficient Node.js Worker Thread Pool implementation",

@@ -45,3 +45,3 @@ "main": "./dist/src/index.js",

"ts-node": "^9.1.1",
"typescript": "^4.2.4"
"typescript": "4.3.x"
},

@@ -48,0 +48,0 @@ "dependencies": {

"use strict";
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
privateMap.set(receiver, value);
return value;
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return privateMap.get(receiver);
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};

@@ -18,3 +16,3 @@ var __importDefault = (this && this.__importDefault) || function (mod) {

};
var _value, _view, _pool;
var _DirectlyTransferable_value, _ArrayBufferViewTransferable_view, _Piscina_pool;
const worker_threads_1 = require("worker_threads");

@@ -96,15 +94,15 @@ const events_1 = require("events");

constructor(value) {
_value.set(this, void 0);
__classPrivateFieldSet(this, _value, value);
_DirectlyTransferable_value.set(this, void 0);
__classPrivateFieldSet(this, _DirectlyTransferable_value, value, "f");
}
get [(_value = new WeakMap(), common_1.kTransferable)]() { return __classPrivateFieldGet(this, _value); }
get [common_1.kValue]() { return __classPrivateFieldGet(this, _value); }
get [(_DirectlyTransferable_value = new WeakMap(), common_1.kTransferable)]() { return __classPrivateFieldGet(this, _DirectlyTransferable_value, "f"); }
get [common_1.kValue]() { return __classPrivateFieldGet(this, _DirectlyTransferable_value, "f"); }
}
class ArrayBufferViewTransferable {
constructor(view) {
_view.set(this, void 0);
__classPrivateFieldSet(this, _view, view);
_ArrayBufferViewTransferable_view.set(this, void 0);
__classPrivateFieldSet(this, _ArrayBufferViewTransferable_view, view, "f");
}
get [(_view = new WeakMap(), common_1.kTransferable)]() { return __classPrivateFieldGet(this, _view).buffer; }
get [common_1.kValue]() { return __classPrivateFieldGet(this, _view); }
get [(_ArrayBufferViewTransferable_view = new WeakMap(), common_1.kTransferable)]() { return __classPrivateFieldGet(this, _ArrayBufferViewTransferable_view, "f").buffer; }
get [common_1.kValue]() { return __classPrivateFieldGet(this, _ArrayBufferViewTransferable_view, "f"); }
}

@@ -671,3 +669,3 @@ let taskIdCounter = 0;

super({ ...options, name: 'Piscina' });
_pool.set(this, void 0);
_Piscina_pool.set(this, void 0);
if (typeof options.filename !== 'string' && options.filename != null) {

@@ -725,3 +723,3 @@ throw new TypeError('options.filename must be a string or null');

}
__classPrivateFieldSet(this, _pool, new ThreadPool(this, options));
__classPrivateFieldSet(this, _Piscina_pool, new ThreadPool(this, options), "f");
}

@@ -751,3 +749,3 @@ /** @deprecated Use run(task, options) instead **/

}
return __classPrivateFieldGet(this, _pool).runTask(task, {
return __classPrivateFieldGet(this, _Piscina_pool, "f").runTask(task, {
transferList,

@@ -776,13 +774,13 @@ filename: filename || null,

}
return __classPrivateFieldGet(this, _pool).runTask(task, { transferList, filename, name, signal });
return __classPrivateFieldGet(this, _Piscina_pool, "f").runTask(task, { transferList, filename, name, signal });
}
destroy() {
return __classPrivateFieldGet(this, _pool).destroy();
return __classPrivateFieldGet(this, _Piscina_pool, "f").destroy();
}
get options() {
return __classPrivateFieldGet(this, _pool).options;
return __classPrivateFieldGet(this, _Piscina_pool, "f").options;
}
get threads() {
const ret = [];
for (const workerInfo of __classPrivateFieldGet(this, _pool).workers) {
for (const workerInfo of __classPrivateFieldGet(this, _Piscina_pool, "f").workers) {
ret.push(workerInfo.worker);

@@ -793,15 +791,15 @@ }

get queueSize() {
const pool = __classPrivateFieldGet(this, _pool);
const pool = __classPrivateFieldGet(this, _Piscina_pool, "f");
return Math.max(pool.taskQueue.size - pool.pendingCapacity(), 0);
}
get completed() {
return __classPrivateFieldGet(this, _pool).completed;
return __classPrivateFieldGet(this, _Piscina_pool, "f").completed;
}
get waitTime() {
const result = hdr_histogram_percentiles_obj_1.default.histAsObj(__classPrivateFieldGet(this, _pool).waitTime);
return hdr_histogram_percentiles_obj_1.default.addPercentiles(__classPrivateFieldGet(this, _pool).waitTime, result);
const result = hdr_histogram_percentiles_obj_1.default.histAsObj(__classPrivateFieldGet(this, _Piscina_pool, "f").waitTime);
return hdr_histogram_percentiles_obj_1.default.addPercentiles(__classPrivateFieldGet(this, _Piscina_pool, "f").waitTime, result);
}
get runTime() {
const result = hdr_histogram_percentiles_obj_1.default.histAsObj(__classPrivateFieldGet(this, _pool).runTime);
return hdr_histogram_percentiles_obj_1.default.addPercentiles(__classPrivateFieldGet(this, _pool).runTime, result);
const result = hdr_histogram_percentiles_obj_1.default.histAsObj(__classPrivateFieldGet(this, _Piscina_pool, "f").runTime);
return hdr_histogram_percentiles_obj_1.default.addPercentiles(__classPrivateFieldGet(this, _Piscina_pool, "f").runTime, result);
}

@@ -813,5 +811,5 @@ get utilization() {

// maximum number of threads.
const capacity = this.duration * __classPrivateFieldGet(this, _pool).options.maxThreads;
const totalMeanRuntime = __classPrivateFieldGet(this, _pool).runTime.mean *
__classPrivateFieldGet(this, _pool).runTime.totalCount;
const capacity = this.duration * __classPrivateFieldGet(this, _Piscina_pool, "f").options.maxThreads;
const totalMeanRuntime = __classPrivateFieldGet(this, _Piscina_pool, "f").runTime.mean *
__classPrivateFieldGet(this, _Piscina_pool, "f").runTime.totalCount;
// We calculate the appoximate pool utilization by multiplying

@@ -830,3 +828,3 @@ // the mean run time of all tasks by the number of runtime

get duration() {
return perf_hooks_1.performance.now() - __classPrivateFieldGet(this, _pool).start;
return perf_hooks_1.performance.now() - __classPrivateFieldGet(this, _Piscina_pool, "f").start;
}

@@ -863,4 +861,4 @@ static get isWorkerThread() {

}
_pool = new WeakMap();
_Piscina_pool = new WeakMap();
module.exports = Piscina;
//# sourceMappingURL=index.js.map

@@ -28,3 +28,3 @@ "use strict";

const handlerCache = new Map();
let useAtomics = true;
let useAtomics = process.env.PISCINA_DISABLE_ATOMICS !== '1';
// Get `import(x)` as a function that isn't transpiled to `require(x)` by

@@ -37,4 +37,4 @@ // TypeScript for dual ESM/CJS support.

if (importESMCached === undefined) {
// eslint-disable-next-line no-eval
importESMCached = eval('(specifier) => import(specifier)');
// eslint-disable-next-line no-new-func
importESMCached = new Function('specifier', 'return import(specifier)');
}

@@ -82,3 +82,3 @@ return importESMCached;

worker_threads_1.parentPort.on('message', (message) => {
useAtomics = message.useAtomics;
useAtomics = process.env.PISCINA_DISABLE_ATOMICS === '1' ? false : message.useAtomics;
const { port, sharedBuffer, filename, name, niceIncrement } = message;

@@ -138,3 +138,3 @@ (async function () {

let response;
const transferList = [];
let transferList = [];
try {

@@ -147,3 +147,3 @@ const handler = await getHandler(filename, name);

if (common_1.isMovable(result)) {
transferList.concat(result[common_1.kTransferable]);
transferList = transferList.concat(result[common_1.kTransferable]);
result = result[common_1.kValue];

@@ -150,0 +150,0 @@ }

{
"name": "piscina",
"version": "3.1.0",
"version": "3.2.0",
"description": "A fast, efficient Node.js Worker Thread Pool implementation",

@@ -45,3 +45,3 @@ "main": "./dist/src/index.js",

"ts-node": "^9.1.1",
"typescript": "^4.2.4"
"typescript": "4.3.x"
},

@@ -48,0 +48,0 @@ "dependencies": {

@@ -306,3 +306,4 @@ ![Piscina Logo](https://avatars1.githubusercontent.com/u/65627548?s=200&v=4)

* `useAtomics`: (`boolean`) Use the [`Atomics`][] API for faster communication
between threads. This is on by default.
between threads. This is on by default. You can disable `Atomics` globally by
setting the environment variable `PISCINA_DISABLE_ATOMICS` to `1`.
* `resourceLimits`: (`object`) See [Node.js new Worker options][]

@@ -786,2 +787,9 @@ * `maxOldGenerationSizeMb`: (`number`) The maximum size of each worker threads

### 3.2.0
* Adds a new `PISCINA_DISABLE_ATOMICS` environment variable as an alternative way of
disabling Piscina's internal use of the `Atomics` API. (https://github.com/piscinajs/piscina/pull/163)
* Fixes a bug with transferable objects. (https://github.com/piscinajs/piscina/pull/155)
* Fixes CI issues with TypeScript. (https://github.com/piscinajs/piscina/pull/161)
### 3.1.0

@@ -788,0 +796,0 @@

@@ -20,3 +20,3 @@ import { parentPort, MessagePort, receiveMessageOnPort, workerData } from 'worker_threads';

const handlerCache : Map<string, Function> = new Map();
let useAtomics : boolean = true;
let useAtomics : boolean = process.env.PISCINA_DISABLE_ATOMICS !== '1';

@@ -30,4 +30,4 @@ // Get `import(x)` as a function that isn't transpiled to `require(x)` by

if (importESMCached === undefined) {
// eslint-disable-next-line no-eval
importESMCached = eval('(specifier) => import(specifier)');
// eslint-disable-next-line no-new-func
importESMCached = new Function('specifier', 'return import(specifier)') as typeof importESMCached;
}

@@ -79,3 +79,3 @@ return importESMCached;

parentPort!.on('message', (message : StartupMessage) => {
useAtomics = message.useAtomics;
useAtomics = process.env.PISCINA_DISABLE_ATOMICS === '1' ? false : message.useAtomics;
const { port, sharedBuffer, filename, name, niceIncrement } = message;

@@ -144,3 +144,3 @@ (async function () {

let response : ResponseMessage;
const transferList : any[] = [];
let transferList : any[] = [];
try {

@@ -153,3 +153,3 @@ const handler = await getHandler(filename, name);

if (isMovable(result)) {
transferList.concat(result[kTransferable]);
transferList = transferList.concat(result[kTransferable]);
result = result[kValue];

@@ -156,0 +156,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc