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 1.2.0 to 1.2.1

examples/server/async-sleep-pooled.js

4

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

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

"devDependencies": {
"@types/node": "^13.13.0",
"@types/node": "^13.13.5",
"@typescript-eslint/eslint-plugin": "^2.28.0",

@@ -38,0 +38,0 @@ "@typescript-eslint/parser": "^2.28.0",

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

var _pool;
const worker_threads_1 = require("worker_threads"); // eslint-disable-line
const worker_threads_1 = require("worker_threads");
const events_1 = require("events");

@@ -33,5 +33,2 @@ const async_hooks_1 = require("async_hooks");

const package_json_1 = require("../package.json");
// TODO(addaleax): Undo when https://github.com/DefinitelyTyped/DefinitelyTyped/pull/44034 is released.
const worker_threads_2 = __importDefault(require("worker_threads")); // eslint-disable-line
const { receiveMessageOnPort } = worker_threads_2.default;
const cpuCount = (() => {

@@ -176,3 +173,3 @@ try {

let entry;
while ((entry = receiveMessageOnPort(this.port)) !== undefined) {
while ((entry = worker_threads_1.receiveMessageOnPort(this.port)) !== undefined) {
this._handleResponse(entry.message);

@@ -193,2 +190,3 @@ }

this.completed = 0;
this.inProcessPendingMessages = false;
this.publicInterface = publicInterface;

@@ -251,7 +249,3 @@ this.workers = [];

}
if (pool.options.useAtomics) {
for (const workerInfo of pool.workers) {
workerInfo.processPendingMessages();
}
}
pool._processPendingMessages();
}

@@ -283,2 +277,16 @@ worker.on('message', (message) => {

}
_processPendingMessages() {
if (this.inProcessPendingMessages || !this.options.useAtomics) {
return;
}
this.inProcessPendingMessages = true;
try {
for (const workerInfo of this.workers) {
workerInfo.processPendingMessages();
}
}
finally {
this.inProcessPendingMessages = false;
}
}
_removeWorker(workerInfo) {

@@ -285,0 +293,0 @@ workerInfo.destroy();

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __importStar = (this && this.__importStar) || function (mod) {

@@ -13,10 +10,7 @@ if (mod && mod.__esModule) return mod;

Object.defineProperty(exports, "__esModule", { value: true });
const worker_threads_1 = require("worker_threads"); // eslint-disable-line
const worker_threads_1 = require("worker_threads");
const url_1 = require("url");
const common_1 = require("./common");
// TODO(addaleax): Undo when https://github.com/DefinitelyTyped/DefinitelyTyped/pull/44034 is released.
const worker_threads_2 = __importDefault(require("worker_threads")); // eslint-disable-line
const { receiveMessageOnPort, workerData } = worker_threads_2.default;
common_1.commonState.isWorkerThread = true;
common_1.commonState.workerData = workerData;
common_1.commonState.workerData = worker_threads_1.workerData;
const handlerCache = new Map();

@@ -101,3 +95,3 @@ let useAtomics = true;

let entry;
while ((entry = receiveMessageOnPort(port)) !== undefined) {
while ((entry = worker_threads_1.receiveMessageOnPort(port)) !== undefined) {
onMessage(port, sharedBuffer, entry.message);

@@ -104,0 +98,0 @@ }

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

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

"devDependencies": {
"@types/node": "^13.13.0",
"@types/node": "^13.13.5",
"@typescript-eslint/eslint-plugin": "^2.28.0",

@@ -38,0 +38,0 @@ "@typescript-eslint/parser": "^2.28.0",

@@ -352,5 +352,2 @@ # piscina - the node.js worker pool

* ESM Support
* Exposing piscina as an ESM
* Allowing Workers to be ESMs
* Improved Documentation

@@ -357,0 +354,0 @@ * More examples

@@ -1,2 +0,2 @@

import { Worker, MessageChannel, MessagePort } from 'worker_threads'; // eslint-disable-line
import { Worker, MessageChannel, MessagePort, receiveMessageOnPort } from 'worker_threads';
import { EventEmitter, once } from 'events';

@@ -14,5 +14,2 @@ import { AsyncResource } from 'async_hooks';

import { version } from '../package.json';
// TODO(addaleax): Undo when https://github.com/DefinitelyTyped/DefinitelyTyped/pull/44034 is released.
import wt from 'worker_threads'; // eslint-disable-line
const { receiveMessageOnPort } = wt as any;

@@ -270,2 +267,3 @@ const cpuCount : number = (() => {

waitTime : Histogram;
inProcessPendingMessages : boolean = false;

@@ -341,7 +339,3 @@ constructor (publicInterface : Piscina, options : Options) {

if (pool.options.useAtomics) {
for (const workerInfo of pool.workers) {
workerInfo.processPendingMessages();
}
}
pool._processPendingMessages();
}

@@ -380,2 +374,17 @@

_processPendingMessages () {
if (this.inProcessPendingMessages || !this.options.useAtomics) {
return;
}
this.inProcessPendingMessages = true;
try {
for (const workerInfo of this.workers) {
workerInfo.processPendingMessages();
}
} finally {
this.inProcessPendingMessages = false;
}
}
_removeWorker (workerInfo : WorkerInfo) : void {

@@ -382,0 +391,0 @@ workerInfo.destroy();

@@ -1,7 +0,4 @@

import { parentPort, MessagePort } from 'worker_threads'; // eslint-disable-line
import { parentPort, MessagePort, receiveMessageOnPort, workerData } from 'worker_threads';
import { pathToFileURL } from 'url';
import { commonState, RequestMessage, ResponseMessage, StartupMessage, kResponseCountField, kRequestCountField } from './common';
// TODO(addaleax): Undo when https://github.com/DefinitelyTyped/DefinitelyTyped/pull/44034 is released.
import wt from 'worker_threads'; // eslint-disable-line
const { receiveMessageOnPort, workerData } = wt as any;

@@ -8,0 +5,0 @@ commonState.isWorkerThread = true;

Sorry, the diff of this file is not supported yet

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