node-worker-threads-pool
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"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); | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
47912
231
205
0