-const DynamicThreadPool = require('../lib/dynamic')
+const { DynamicThreadPool } = require('poolifier')
let resolved = 0
let maxReached = 0
const pool = new DynamicThreadPool(10, 20, './yourWorker.js', {
-const FixedThreadPool = require('../lib/fixed')
+const { FixedThreadPool } = require('poolifier')
const pool = new FixedThreadPool(15, './multifunctionWorker.js', {
errorHandler: e => console.error(e),
onlineHandler: () => console.log('worker is online')
'use strict'
-const { ThreadWorker } = require('../lib/workers')
+const { ThreadWorker } = require('poolifier')
function yourFunction (data) {
if (data.fname === 'fn0') {
-const FixedThreadPool = require('../lib/fixed')
+const { FixedThreadPool } = require('poolifier')
let resolved = 0
const pool = new FixedThreadPool(15, './yourWorker.js', {
errorHandler: e => console.error(e),
'use strict'
-const { ThreadWorker } = require('../lib/workers')
+const { ThreadWorker } = require('poolifier')
function yourFunction (data) {
for (let i = 0; i <= 1000; i++) {
/* eslint-disable @typescript-eslint/strict-boolean-expressions */
-import FixedThreadPool, {
+import {
+ FixedThreadPool,
FixedThreadPoolOptions,
WorkerWithMessageChannel
} from './fixed'
* @author [Alessandro Pio Ardizio](https://github.com/pioardi)
* @since 0.0.1
*/
-export default class DynamicThreadPool<
+export class DynamicThreadPool<
Data = any,
Response = any
> extends FixedThreadPool<Data, Response> {
}
}
}
-
-module.exports = DynamicThreadPool
* @author [Alessandro Pio Ardizio](https://github.com/pioardi)
* @since 0.0.1
*/
-export default class FixedThreadPool<Data = any, Response = any> {
+export class FixedThreadPool<Data = any, Response = any> {
public readonly workers: WorkerWithMessageChannel[] = []
public nextWorker: number = 0
return worker
}
}
-
-module.exports = FixedThreadPool
-import DynamicThreadPool from './dynamic'
-import FixedThreadPool from './fixed'
+import { DynamicThreadPool } from './dynamic'
+import { FixedThreadPool } from './fixed'
import { ThreadWorker } from './workers'
export {
export { DynamicThreadPoolOptions } from './dynamic'
export { ThreadWorkerOptions } from './workers'
export { FixedThreadPool, DynamicThreadPool, ThreadWorker }
-
-module.exports = { FixedThreadPool, DynamicThreadPool, ThreadWorker }
const expect = require('expect')
-const DynamicThreadPool = require('../lib/dynamic')
+const { DynamicThreadPool } = require('../lib/dynamic')
const min = 1
const max = 3
const pool = new DynamicThreadPool(min, max, './tests/workers/testWorker.js', {
const expect = require('expect')
-const FixedThreadPool = require('../lib/fixed')
+const { FixedThreadPool } = require('../lib/fixed')
const numThreads = 10
const pool = new FixedThreadPool(numThreads, './tests/workers/testWorker.js', {
errorHandler: e => console.error(e),