- Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
- Optimize tasks usage lookup implementation.
+### Fixed
+
+- Fix missed pool event emitter type export.
+- Fix typedoc documentation generation.
+
## [2.3.4] - 2022-10-17
### Added
export { DynamicClusterPool } from './pools/cluster/dynamic'
export { FixedClusterPool } from './pools/cluster/fixed'
export type { ClusterPoolOptions } from './pools/cluster/fixed'
-export type { IPool, PoolOptions } from './pools/pool'
+export type { IPool, PoolEmitter, PoolOptions } from './pools/pool'
export type {
ErrorHandler,
ExitHandler,
- IPoolWorker,
MessageHandler,
OnlineHandler
} from './pools/pool-worker'
export { DynamicThreadPool } from './pools/thread/dynamic'
export { FixedThreadPool } from './pools/thread/fixed'
export type { ThreadWorkerWithMessageChannel } from './pools/thread/fixed'
-export { AbstractWorker } from './worker/abstract-worker'
export { ClusterWorker } from './worker/cluster-worker'
export { ThreadWorker } from './worker/thread-worker'
export { KillBehaviors } from './worker/worker-options'
import { EMPTY_FUNCTION } from '../utils'
import { isKillBehavior, KillBehaviors } from '../worker/worker-options'
import type { PoolOptions } from './pool'
+import { PoolEmitter } from './pool'
import type { IPoolInternal, TasksUsage } from './pool-internal'
-import { PoolEmitter, PoolType } from './pool-internal'
+import { PoolType } from './pool-internal'
import type { IPoolWorker } from './pool-worker'
import {
WorkerChoiceStrategies,
* This cluster pool creates new workers when the others are busy, up to the maximum number of workers.
* When the maximum number of workers is reached, an event is emitted. If you want to listen to this event, use the pool's `emitter`.
*
- * @template DataType of data sent to the worker. This can only be serializable data.
- * @template ResponseType of response of execution. This can only be serializable data.
+ * @template Data Type of data sent to the worker. This can only be serializable data.
+ * @template Response Type of response of execution. This can only be serializable data.
* @author [Christopher Quadflieg](https://github.com/Shinigami92)
* @since 2.0.0
*/
*
* This pool selects the workers in a round robin fashion.
*
- * @template DataType of data sent to the worker. This can only be serializable data.
- * @template ResponseType of response of execution. This can only be serializable data.
+ * @template Data Type of data sent to the worker. This can only be serializable data.
+ * @template Response Type of response of execution. This can only be serializable data.
* @author [Christopher Quadflieg](https://github.com/Shinigami92)
* @since 2.0.0
*/
-import EventEmitter from 'events'
import type { IPool } from './pool'
import type { IPoolWorker } from './pool-worker'
/**
- * Pool types.
+ * Internal pool types.
*/
export enum PoolType {
FIXED = 'fixed',
}
/**
- * Tasks usage statistics.
+ * Internal tasks usage statistics.
*/
export interface TasksUsage {
run: number
avgRunTime: number
}
-/**
- * Internal poolifier pool emitter.
- */
-export class PoolEmitter extends EventEmitter {}
-
/**
* Internal contract definition for a poolifier pool.
*
*/
readonly workersTasksUsage: Map<Worker, TasksUsage>
- /**
- * Emitter on which events can be listened to.
- *
- * Events that can currently be listened to:
- *
- * - `'busy'`
- */
- readonly emitter?: PoolEmitter
-
/**
* Pool type.
*
-import type { Worker as ClusterWorker } from 'cluster'
-import type { Worker as WorkerThread } from 'worker_threads'
-import type { Draft } from '../utility-types'
-
-/**
- * Poolifier supported worker type.
- */
-export type WorkerType = WorkerThread & ClusterWorker & Draft<MessageChannel>
-
/**
* Callback invoked if the worker has received a message.
*/
+import EventEmitter from 'events'
import type {
ErrorHandler,
ExitHandler,
} from './pool-worker'
import type { WorkerChoiceStrategy } from './selection-strategies/selection-strategies-types'
+/**
+ * Pool events emitter.
+ */
+export class PoolEmitter extends EventEmitter {}
+
/**
* Options for a poolifier pool.
*/
* @template Response Type of response of execution. This can only be serializable data.
*/
export interface IPool<Data = unknown, Response = unknown> {
+ /**
+ * Emitter on which events can be listened to.
+ *
+ * Events that can currently be listened to:
+ *
+ * - `'busy'`
+ */
+ readonly emitter?: PoolEmitter
/**
* Performs the task specified in the constructor with the data parameter.
*
* This thread pool creates new threads when the others are busy, up to the maximum number of threads.
* When the maximum number of threads is reached, an event is emitted. If you want to listen to this event, use the pool's `emitter`.
*
- * @template DataType of data sent to the worker. This can only be serializable data.
- * @template ResponseType of response of execution. This can only be serializable data.
+ * @template Data Type of data sent to the worker. This can only be serializable data.
+ * @template Response Type of response of execution. This can only be serializable data.
* @author [Alessandro Pio Ardizio](https://github.com/pioardi)
* @since 0.0.1
*/
*
* This pool selects the threads in a round robin fashion.
*
- * @template DataType of data sent to the worker. This can only be serializable data.
- * @template ResponseType of response of execution. This can only be serializable data.
+ * @template Data Type of data sent to the worker. This can only be serializable data.
+ * @template Response Type of response of execution. This can only be serializable data.
* @author [Alessandro Pio Ardizio](https://github.com/pioardi)
* @since 0.0.1
*/
* If you use a `DynamicClusterPool` the extra workers that were created will be terminated,
* but the minimum number of workers will be guaranteed.
*
- * @template DataType of data this worker receives from pool's execution. This can only be serializable data.
- * @template ResponseType of response the worker sends back to the main worker. This can only be serializable data.
+ * @template Data Type of data this worker receives from pool's execution. This can only be serializable data.
+ * @template Response Type of response the worker sends back to the main worker. This can only be serializable data.
* @author [Christopher Quadflieg](https://github.com/Shinigami92)
* @since 2.0.0
*/
* If you use a `DynamicThreadPool` the extra workers that were created will be terminated,
* but the minimum number of workers will be guaranteed.
*
- * @template DataType of data this worker receives from pool's execution. This can only be serializable data.
- * @template ResponseType of response the worker sends back to the main thread. This can only be serializable data.
+ * @template Data Type of data this worker receives from pool's execution. This can only be serializable data.
+ * @template Response Type of response the worker sends back to the main thread. This can only be serializable data.
* @author [Alessandro Pio Ardizio](https://github.com/pioardi)
* @since 0.0.1
*/
"importsNotUsedAsValues": "error"
},
"include": ["**/*.ts"],
- "exclude": ["node_modules"]
+ "exclude": ["node_modules", "examples/typescript"]
}
{
- "entryPoints": ["src/index.ts"],
+ "entryPoints": ["src"],
"out": "docs",
"readme": "none"
}