WorkerUsage,
} from './pools/worker.js'
export { WorkerTypes } from './pools/worker.js'
-export type { PriorityQueue } from './priority-queue.js'
+export type { PriorityQueue } from './queues/priority-queue.js'
+export type { FixedQueueNode, IFixedQueue } from './queues/queue-types.js'
export type {
- IFixedQueue,
MessageValue,
PromiseResponseWrapper,
Task,
import { performance } from 'node:perf_hooks'
import type { TransferListItem } from 'node:worker_threads'
-import {
- defaultBucketSize,
- type MessageValue,
- type PromiseResponseWrapper,
- type Task,
- type TaskFunctionProperties,
+import { defaultBucketSize } from '../queues/queue-types.js'
+import type {
+ MessageValue,
+ PromiseResponseWrapper,
+ Task,
+ TaskFunctionProperties,
} from '../utility-types.js'
import {
average,
import { MessageChannel } from 'node:worker_threads'
import { CircularBuffer } from '../circular-buffer.js'
-import { PriorityQueue } from '../priority-queue.js'
+import { PriorityQueue } from '../queues/priority-queue.js'
import type { Task } from '../utility-types.js'
import { DEFAULT_TASK_NAME } from '../utils.js'
import {
defaultQueueSize,
type FixedQueueNode,
type IFixedQueue,
-} from './utility-types.js'
+} from './queue-types.js'
/**
* Base fixed queue class
import { AbstractFixedQueue } from './abstract-fixed-queue.js'
-import type { IFixedQueue } from './utility-types.js'
+import type { IFixedQueue } from './queue-types.js'
/**
* Fixed priority queue.
import { AbstractFixedQueue } from './abstract-fixed-queue.js'
-import type { IFixedQueue } from './utility-types.js'
+import type { IFixedQueue } from './queue-types.js'
/**
* Fixed queue.
type FixedQueueNode,
type IFixedQueue,
type PriorityQueueNode,
-} from './utility-types.js'
+} from './queue-types.js'
/**
* Priority queue.
--- /dev/null
+/**
+ * Default queue size.
+ * @internal
+ */
+export const defaultQueueSize = 2048
+
+/**
+ * Fixed queue node.
+ * @typeParam T - Type of fixed queue node data.
+ * @internal
+ */
+export interface FixedQueueNode<T> {
+ data: T
+ priority: number
+}
+
+/**
+ * Fixed queue.
+ * @typeParam T - Type of fixed queue data.
+ * @internal
+ */
+export interface IFixedQueue<T> {
+ /** The fixed queue capacity. */
+ readonly capacity: number
+ /** The fixed queue size. */
+ readonly size: number
+ /** The fixed queue node array. */
+ nodeArray: FixedQueueNode<T>[]
+ /**
+ * Checks if the fixed queue is empty.
+ * @returns `true` if the fixed queue is empty, `false` otherwise.
+ */
+ empty: () => boolean
+ /**
+ * Checks if the fixed queue is full.
+ * @returns `true` if the fixed queue is full, `false` otherwise.
+ */
+ full: () => boolean
+ /**
+ * Enqueue data into the fixed queue.
+ * @param data - Data to enqueue.
+ * @param priority - Priority of the data. Lower values have higher priority.
+ * @returns The new size of the fixed queue.
+ * @throws If the fixed queue is full.
+ */
+ enqueue: (data: T, priority?: number) => number
+ /**
+ * Gets data from the fixed queue.
+ * @param index - The index of the data to get.
+ * @returns The data at the index or `undefined` if the fixed queue is empty or the index is out of bounds.
+ */
+ get: (index: number) => T | undefined
+ /**
+ * Dequeue data from the fixed queue.
+ * @returns The dequeued data or `undefined` if the fixed queue is empty.
+ */
+ dequeue: () => T | undefined
+ /**
+ * Clears the fixed queue.
+ */
+ clear: () => void
+ /**
+ * Returns an iterator for the fixed queue.
+ * @returns An iterator for the fixed queue.
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols
+ */
+ [Symbol.iterator]: () => Iterator<T>
+}
+
+/**
+ * Default bucket size.
+ * @internal
+ */
+export const defaultBucketSize = 2048
+
+/**
+ * Priority queue node.
+ * @typeParam T - Type of priority queue node data.
+ * @internal
+ */
+export interface PriorityQueueNode<T> extends IFixedQueue<T> {
+ next?: IFixedQueue<T>
+}
* @internal
*/
export type Writable<T> = { -readonly [P in keyof T]: T[P] }
-
-/**
- * Default queue size.
- * @internal
- */
-export const defaultQueueSize = 2048
-
-/**
- * Fixed queue node.
- * @typeParam T - Type of fixed queue node data.
- * @internal
- */
-export interface FixedQueueNode<T> {
- data: T
- priority: number
-}
-
-/**
- * Fixed queue.
- * @typeParam T - Type of fixed queue data.
- * @internal
- */
-export interface IFixedQueue<T> {
- /** The fixed queue capacity. */
- readonly capacity: number
- /** The fixed queue size. */
- readonly size: number
- /** The fixed queue node array. */
- nodeArray: FixedQueueNode<T>[]
- /**
- * Checks if the fixed queue is empty.
- * @returns `true` if the fixed queue is empty, `false` otherwise.
- */
- empty: () => boolean
- /**
- * Checks if the fixed queue is full.
- * @returns `true` if the fixed queue is full, `false` otherwise.
- */
- full: () => boolean
- /**
- * Enqueue data into the fixed queue.
- * @param data - Data to enqueue.
- * @param priority - Priority of the data. Lower values have higher priority.
- * @returns The new size of the fixed queue.
- * @throws If the fixed queue is full.
- */
- enqueue: (data: T, priority?: number) => number
- /**
- * Gets data from the fixed queue.
- * @param index - The index of the data to get.
- * @returns The data at the index or `undefined` if the fixed queue is empty or the index is out of bounds.
- */
- get: (index: number) => T | undefined
- /**
- * Dequeue data from the fixed queue.
- * @returns The dequeued data or `undefined` if the fixed queue is empty.
- */
- dequeue: () => T | undefined
- /**
- * Clears the fixed queue.
- */
- clear: () => void
- /**
- * Returns an iterator for the fixed queue.
- * @returns An iterator for the fixed queue.
- * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols
- */
- [Symbol.iterator]: () => Iterator<T>
-}
-
-/**
- * Default bucket size.
- * @internal
- */
-export const defaultBucketSize = 2048
-
-/**
- * Priority queue node.
- * @typeParam T - Type of priority queue node data.
- * @internal
- */
-export interface PriorityQueueNode<T> extends IFixedQueue<T> {
- next?: IFixedQueue<T>
-}
WorkerTypes,
} from '../../lib/index.cjs'
import { WorkerNode } from '../../lib/pools/worker-node.cjs'
-import { PriorityQueue } from '../../lib/priority-queue.cjs'
-import { defaultBucketSize } from '../../lib/utility-types.cjs'
+import { PriorityQueue } from '../../lib/queues/priority-queue.cjs'
+import { defaultBucketSize } from '../../lib/queues/queue-types.cjs'
import { DEFAULT_TASK_NAME } from '../../lib/utils.cjs'
import { waitPoolEvents } from '../test-utils.cjs'
import { CircularBuffer } from '../../lib/circular-buffer.cjs'
import { WorkerTypes } from '../../lib/index.cjs'
import { WorkerNode } from '../../lib/pools/worker-node.cjs'
-import { PriorityQueue } from '../../lib/priority-queue.cjs'
+import { PriorityQueue } from '../../lib/queues/priority-queue.cjs'
import { DEFAULT_TASK_NAME } from '../../lib/utils.cjs'
describe('Worker node test suite', () => {
import { expect } from 'expect'
-import { FixedPriorityQueue } from '../lib/fixed-priority-queue.cjs'
-import { defaultQueueSize } from '../lib/utility-types.cjs'
+import { FixedPriorityQueue } from '../../lib/queues/fixed-priority-queue.cjs'
+import { defaultQueueSize } from '../../lib/queues/queue-types.cjs'
describe('Fixed priority queue test suite', () => {
it('Verify constructor() behavior', () => {
import { expect } from 'expect'
-import { FixedQueue } from '../lib/fixed-queue.cjs'
-import { defaultQueueSize } from '../lib/utility-types.cjs'
+import { FixedQueue } from '../../lib/queues/fixed-queue.cjs'
+import { defaultQueueSize } from '../../lib/queues/queue-types.cjs'
describe('Fixed queue test suite', () => {
it('Verify constructor() behavior', () => {
import { expect } from 'expect'
-import { FixedPriorityQueue } from '../lib/fixed-priority-queue.cjs'
-import { FixedQueue } from '../lib/fixed-queue.cjs'
-import { PriorityQueue } from '../lib/priority-queue.cjs'
-import { defaultBucketSize } from '../lib/utility-types.cjs'
+import { FixedPriorityQueue } from '../../lib/queues/fixed-priority-queue.cjs'
+import { FixedQueue } from '../../lib/queues/fixed-queue.cjs'
+import { PriorityQueue } from '../../lib/queues/priority-queue.cjs'
+import { defaultBucketSize } from '../../lib/queues/queue-types.cjs'
describe('Priority queue test suite', () => {
it('Verify constructor() behavior', () => {