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

node-worker-threads-pool

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-worker-threads-pool - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

2

package.json
{
"name": "node-worker-threads-pool",
"version": "0.1.0",
"version": "0.1.1",
"description": "simple worker pool using node's worker_threads api.",

@@ -5,0 +5,0 @@ "main": "index.js",

# node-worker-threads-pool
[![](https://img.shields.io/npm/v/node-worker-threads-pool.svg)](https://www.npmjs.com/package/node-worker-threads-pool)
![](https://img.shields.io/badge/dependencies-none-brightgreen.svg)
![](https://img.shields.io/npm/dt/node-worker-threads-pool.svg)
![](https://img.shields.io/npm/l/node-worker-threads-pool.svg)
Simple worker threads pool using Node's worker_threads module.

@@ -7,3 +13,3 @@

1. This module can only run in Node.js.
2. Since Node's worker_threads module is still in stage of **Experimental**, this module can be accessed only if the --experimental-worker flag is added.
2. Since Node's worker_threads module is still in stage of **Experimental**, this module can be accessed only if the `--experimental-worker` flag is added.

@@ -18,3 +24,3 @@ ## Installation

### `Class: StaticPool`
## `Class: StaticPool`
Instance of StaticPool is a threads pool with static task provided.

@@ -111,3 +117,3 @@

size: 4,
task: function fib(n) {
task: function(n) {
const num = workerData.num;

@@ -132,3 +138,3 @@ for (let i = 0; i < num; i++) {

### `Class: DynamicPool`
## `Class: DynamicPool`
Instance of DynamicPool is a threads pool executes dynamic task function provided every call.

@@ -135,0 +141,0 @@

@@ -64,2 +64,3 @@ const WaitingQueue = require('./waiting-queue');

if (i !== -1) {
worker.terminate();
this.workers[i] = this.newWorker();

@@ -66,0 +67,0 @@ }

@@ -46,5 +46,13 @@ const Pool = require('./pool');

/**
* choose a idle worker to run the task
* with param provided.
* @param { * } param
*/
exec(param) {
if (typeof param === 'function') {
throw new Error('"param" can not be a function!');
}
return this.runTask(param);
}
}
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