{
  "version": 3,
  "sources": ["../../../src/master/pool-node.ts", "../../../src/master/implementation.node.ts", "../../../src/master/pool-types.ts", "../../../src/symbols.ts", "../../../src/master/thread.ts"],
  "sourcesContent": ["/* eslint-disable import-x/export */\n/* eslint-disable unicorn/no-thenable */\n\n/* eslint-disable @typescript-eslint/member-ordering */\n/* eslint-disable unicorn/no-array-reduce */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-namespace */\n\n/// <reference lib=\"esnext\" />\n\nimport DebugLogger from 'debug'\nimport {\n  multicast, Observable, Subject,\n} from 'observable-fns'\n\nimport { defaultPoolSize } from './implementation.node.ts'\nimport type {\n  PoolEvent, QueuedTask, TaskRunFunction, WorkerDescriptor,\n} from './pool-types.ts'\nimport { PoolEventType } from './pool-types.ts'\nimport { Thread } from './thread.ts'\n\nexport declare namespace Pool {\n  type Event<ThreadType extends Thread = any> = PoolEvent<ThreadType>\n  type EventType = PoolEventType\n}\n\nlet nextPoolID = 1\n\nfunction createArray(size: number): number[] {\n  const array: number[] = []\n  for (let index = 0; index < size; index++) {\n    array.push(index)\n  }\n  return array\n}\n\nfunction delay(ms: number) {\n  return new Promise(resolve => setTimeout(resolve, ms))\n}\n\nfunction flatMap<In, Out>(array: In[], mapper: (element: In) => Out[]): Out[] {\n  return array.reduce<Out[]>((flattened, element) => [...flattened, ...mapper(element)], [])\n}\n\nfunction slugify(text: string) {\n  return text.replaceAll(/\\W/g, ' ').trim().replaceAll(/\\s+/g, '-')\n}\n\nfunction spawnWorkers<ThreadType extends Thread>(spawnWorker: () => Promise<ThreadType>, count: number): WorkerDescriptor<ThreadType>[] {\n  return createArray(count).map(\n    (): WorkerDescriptor<ThreadType> => ({\n      init: spawnWorker(),\n      runningTasks: [],\n    }),\n  )\n}\n\n/**\n * Thread pool managing a set of worker threads.\n * Use it to queue tasks that are run on those threads with limited\n * concurrency.\n */\nexport interface Pool<ThreadType extends Thread> {\n  /**\n   * Returns a promise that resolves once the task queue is emptied.\n   * Promise will be rejected if any task fails.\n   *\n   * @param allowResolvingImmediately Set to `true` to resolve immediately if task queue is currently empty.\n   */\n  completed(allowResolvingImmediately?: boolean): Promise<any>\n\n  /**\n   * Returns a promise that resolves once the task queue is emptied.\n   * Failing tasks will not cause the promise to be rejected.\n   *\n   * @param allowResolvingImmediately Set to `true` to resolve immediately if task queue is currently empty.\n   */\n  settled(allowResolvingImmediately?: boolean): Promise<Error[]>\n\n  /**\n   * Returns an observable that yields pool events.\n   */\n  events(): Observable<PoolEvent<ThreadType>>\n\n  /**\n   * Queue a task and return a promise that resolves once the task has been dequeued,\n   * started and finished.\n   *\n   * @param task An async function that takes a thread instance and invokes it.\n   */\n  queue<Return>(task: TaskRunFunction<ThreadType, Return>): QueuedTask<ThreadType, Return>\n\n  /**\n   * Terminate all pool threads.\n   *\n   * @param force Set to `true` to kill the thread even if it cannot be stopped gracefully.\n   */\n  terminate(force?: boolean): Promise<void>\n}\n\ninterface PoolOptions {\n  /** Maximum no. of tasks to run on one worker thread at a time. Defaults to one. */\n  concurrency?: number\n\n  /** Maximum no. of jobs to be queued for execution before throwing an error. */\n  maxQueuedJobs?: number\n\n  /** Gives that pool a name to be used for debug logging, letting you distinguish between log output of different pools. */\n  name?: string\n\n  /** No. of worker threads to spawn and to be managed by the pool. */\n  size?: number\n}\n\nclass WorkerPool<ThreadType extends Thread> implements Pool<ThreadType> {\n  static EventType = PoolEventType\n\n  private readonly debug: DebugLogger.Debugger\n  private readonly eventObservable: Observable<PoolEvent<ThreadType>>\n  private readonly options: PoolOptions\n  private readonly workers: WorkerDescriptor<ThreadType>[]\n\n  private readonly eventSubject = new Subject<PoolEvent<ThreadType>>()\n  private initErrors: Error[] = []\n  private isClosing = false\n  private nextTaskID = 1\n  private taskQueue: QueuedTask<ThreadType, any>[] = []\n\n  constructor(spawnWorker: () => Promise<ThreadType>, optionsOrSize?: number | PoolOptions) {\n    const options: PoolOptions = typeof optionsOrSize === 'number' ? { size: optionsOrSize } : optionsOrSize || {}\n\n    const { size = defaultPoolSize } = options\n\n    this.debug = DebugLogger(`threads:pool:${slugify(options.name ?? String(nextPoolID++))}`)\n    this.options = options\n    this.workers = spawnWorkers(spawnWorker, size)\n\n    this.eventObservable = multicast(Observable.from(this.eventSubject))\n\n    Promise.all(this.workers.map(worker => worker.init)).then(\n      () =>\n        this.eventSubject.next({\n          size: this.workers.length,\n          type: PoolEventType.initialized,\n        }),\n      (error) => {\n        this.debug('Error while initializing pool worker:', error)\n        this.eventSubject.error(error)\n        this.initErrors.push(error)\n      },\n    )\n  }\n\n  private findIdlingWorker(): WorkerDescriptor<ThreadType> | undefined {\n    const { concurrency = 1 } = this.options\n    return this.workers.find(worker => worker.runningTasks.length < concurrency)\n  }\n\n  private async runPoolTask(worker: WorkerDescriptor<ThreadType>, task: QueuedTask<ThreadType, any>) {\n    const workerID = this.workers.indexOf(worker) + 1\n\n    this.debug(`Running task #${task.id} on worker #${workerID}...`)\n    this.eventSubject.next({\n      taskID: task.id,\n      type: PoolEventType.taskStart,\n      workerID,\n    })\n\n    try {\n      const returnValue = await task.run(await worker.init)\n\n      this.debug(`Task #${task.id} completed successfully`)\n      this.eventSubject.next({\n        returnValue,\n        taskID: task.id,\n        type: PoolEventType.taskCompleted,\n        workerID,\n      })\n    } catch (ex) {\n      const error = ex as Error\n      this.debug(`Task #${task.id} failed`)\n      this.eventSubject.next({\n        error,\n        taskID: task.id,\n        type: PoolEventType.taskFailed,\n        workerID,\n      })\n    }\n  }\n\n  private run(worker: WorkerDescriptor<ThreadType>, task: QueuedTask<ThreadType, any>) {\n    const runPromise = (async () => {\n      const removeTaskFromWorkersRunningTasks = () => {\n        worker.runningTasks = worker.runningTasks.filter(someRunPromise => someRunPromise !== runPromise)\n      }\n\n      // Defer task execution by one tick to give handlers time to subscribe\n      await delay(0)\n\n      try {\n        await this.runPoolTask(worker, task)\n      } finally {\n        removeTaskFromWorkersRunningTasks()\n\n        if (!this.isClosing) {\n          this.scheduleWork()\n        }\n      }\n    })()\n\n    worker.runningTasks.push(runPromise)\n  }\n\n  private scheduleWork() {\n    this.debug('Attempt de-queueing a task in order to run it...')\n\n    const availableWorker = this.findIdlingWorker()\n    if (!availableWorker) return\n\n    const nextTask = this.taskQueue.shift()\n    if (!nextTask) {\n      this.debug('Task queue is empty')\n      this.eventSubject.next({ type: PoolEventType.taskQueueDrained })\n      return\n    }\n\n    this.run(availableWorker, nextTask)\n  }\n\n  private taskCompletion(taskID: number) {\n    return new Promise<any>((resolve, reject) => {\n      const eventSubscription = this.events().subscribe((event) => {\n        if (event.type === PoolEventType.taskCompleted && event.taskID === taskID) {\n          eventSubscription.unsubscribe()\n          resolve(event.returnValue)\n        } else if (event.type === PoolEventType.taskFailed && event.taskID === taskID) {\n          eventSubscription.unsubscribe()\n          reject(event.error)\n        } else if (event.type === PoolEventType.terminated) {\n          eventSubscription.unsubscribe()\n          reject(new Error('Pool has been terminated before task was run.'))\n        }\n      })\n    })\n  }\n\n  async settled(allowResolvingImmediately = false): Promise<Error[]> {\n    const getCurrentlyRunningTasks = () => flatMap(this.workers, worker => worker.runningTasks)\n\n    const taskFailures: Error[] = []\n\n    const failureSubscription = this.eventObservable.subscribe((event) => {\n      if (event.type === PoolEventType.taskFailed) {\n        taskFailures.push(event.error)\n      }\n    })\n\n    if (this.initErrors.length > 0) {\n      throw this.initErrors[0]\n    }\n    if (allowResolvingImmediately && this.taskQueue.length === 0) {\n      await Promise.allSettled(getCurrentlyRunningTasks())\n      return taskFailures\n    }\n\n    await new Promise<void>((resolve, reject) => {\n      const subscription = this.eventObservable.subscribe({\n        error: reject,\n        next(event) {\n          if (event.type === PoolEventType.taskQueueDrained) {\n            subscription.unsubscribe()\n            resolve(void 0)\n          }\n        }, // make a pool-wide error reject the completed() result promise\n      })\n    })\n\n    await Promise.allSettled(getCurrentlyRunningTasks())\n    failureSubscription.unsubscribe()\n\n    return taskFailures\n  }\n\n  async completed(allowResolvingImmediately = false) {\n    const settlementPromise = this.settled(allowResolvingImmediately)\n\n    const earlyExitPromise = new Promise<Error[]>((resolve, reject) => {\n      const subscription = this.eventObservable.subscribe({\n        error: reject,\n        next(event) {\n          if (event.type === PoolEventType.taskQueueDrained) {\n            subscription.unsubscribe()\n            resolve(settlementPromise)\n          } else if (event.type === PoolEventType.taskFailed) {\n            subscription.unsubscribe()\n            reject(event.error)\n          }\n        }, // make a pool-wide error reject the completed() result promise\n      })\n    })\n\n    const errors = await Promise.race([settlementPromise, earlyExitPromise])\n\n    if (errors.length > 0) {\n      throw errors[0]\n    }\n  }\n\n  events() {\n    return this.eventObservable\n  }\n\n  queue(taskFunction: TaskRunFunction<ThreadType, any>) {\n    const { maxQueuedJobs = Number.POSITIVE_INFINITY } = this.options\n\n    if (this.isClosing) {\n      throw new Error('Cannot schedule pool tasks after terminate() has been called.')\n    }\n    if (this.initErrors.length > 0) {\n      throw this.initErrors[0]\n    }\n\n    const taskID = this.nextTaskID++\n    const taskCompletion = this.taskCompletion(taskID)\n\n    taskCompletion.catch((error) => {\n      // Prevent unhandled rejections here as we assume the user will use\n      // `pool.completed()`, `pool.settled()` or `task.catch()` to handle errors\n      this.debug(`Task #${taskID} errored:`, error)\n    })\n\n    const task: QueuedTask<ThreadType, any> = {\n      cancel: () => {\n        if (!this.taskQueue.includes(task)) return\n        this.taskQueue = this.taskQueue.filter(someTask => someTask !== task)\n        this.eventSubject.next({\n          taskID: task.id,\n          type: PoolEventType.taskCanceled,\n        })\n      },\n      id: taskID,\n      run: taskFunction,\n      then: taskCompletion.then.bind(taskCompletion),\n    }\n\n    if (this.taskQueue.length >= maxQueuedJobs) {\n      throw new Error(\n        'Maximum number of pool tasks queued. Refusing to queue another one.\\n'\n        + 'This usually happens for one of two reasons: We are either at peak '\n        + \"workload right now or some tasks just won't finish, thus blocking the pool.\",\n      )\n    }\n\n    this.debug(`Queueing task #${task.id}...`)\n    this.taskQueue.push(task)\n\n    this.eventSubject.next({\n      taskID: task.id,\n      type: PoolEventType.taskQueued,\n    })\n\n    this.scheduleWork()\n    return task\n  }\n\n  async terminate(force?: boolean) {\n    this.isClosing = true\n    if (!force) {\n      await this.completed(true)\n    }\n    this.eventSubject.next({\n      remainingQueue: [...this.taskQueue],\n      type: PoolEventType.terminated,\n    })\n    this.eventSubject.complete()\n    await Promise.all(this.workers.map(async worker => Thread.terminate(await worker.init)))\n  }\n}\n\n/**\n * Thread pool constructor. Creates a new pool and spawns its worker threads.\n */\nfunction PoolConstructor<ThreadType extends Thread>(spawnWorker: () => Promise<ThreadType>, optionsOrSize?: number | PoolOptions) {\n  // The function exists only so we don't need to use `new` to create a pool (we still can, though).\n  // If the Pool is a class or not is an implementation detail that should not concern the user.\n  return new WorkerPool(spawnWorker, optionsOrSize)\n}\n\n;(PoolConstructor as any).EventType = PoolEventType\n\n/**\n * Thread pool constructor. Creates a new pool and spawns its worker threads.\n */\nexport const Pool = PoolConstructor as typeof PoolConstructor & { EventType: typeof PoolEventType }\n\nexport type { PoolEvent, QueuedTask } from './pool-types.ts'\nexport { PoolEventType } from './pool-types.ts'\nexport { Thread } from './thread.ts'\n", "/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable unicorn/text-encoding-identifier-case */\n\nimport { cpus } from 'node:os'\nimport path from 'node:path'\nimport { cwd } from 'node:process'\nimport { isMainThread, Worker as NativeWorker } from 'node:worker_threads'\n\nimport type {\n  ImplementationExport, ThreadsWorkerOptions, WorkerImplementation,\n// eslint-disable-next-line import-x/no-internal-modules\n} from '../types/master.ts'\n\n/** Default thread pool size based on the number of CPU cores. */\nexport const defaultPoolSize = cpus().length\n\nfunction resolveScriptPath(scriptPath: string, baseURL?: string | undefined) {\n  const makeAbsolute = (filePath: string) => {\n    return path.isAbsolute(filePath) ? filePath : path.join(baseURL ?? cwd(), filePath)\n  }\n\n  const absolutePath = makeAbsolute(scriptPath)\n  return absolutePath\n}\n\nfunction initWorkerThreadsWorker(): ImplementationExport {\n  let allWorkers: NativeWorker[] = []\n\n  class Worker extends NativeWorker {\n    private mappedEventListeners: WeakMap<EventListener, EventListener>\n\n    constructor(scriptPath: string, options?: ThreadsWorkerOptions & { fromSource: boolean }) {\n      const resolvedScriptPath = options?.fromSource ? null : resolveScriptPath(scriptPath, options?._baseURL)\n      if (resolvedScriptPath === null) {\n        // `options.fromSource` is true\n        const sourceCode = scriptPath\n        super(sourceCode, { ...options, eval: true })\n      } else {\n        super(resolvedScriptPath, options)\n      }\n\n      this.mappedEventListeners = new WeakMap()\n      allWorkers.push(this)\n    }\n\n    addEventListener(eventName: string, rawListener: EventListener) {\n      const listener = (message: any) => {\n        rawListener({ data: message } as any)\n      }\n      this.mappedEventListeners.set(rawListener, listener)\n      this.on(eventName, listener)\n    }\n\n    removeEventListener(eventName: string, rawListener: EventListener) {\n      const listener = this.mappedEventListeners.get(rawListener) || rawListener\n      this.off(eventName, listener)\n    }\n  }\n\n  const terminateWorkersAndMaster = () => {\n    // we should terminate all workers and then gracefully shutdown self process\n    Promise.all(allWorkers.map(worker => worker.terminate())).then(\n      () => process.exit(0),\n      () => process.exit(1),\n    )\n    allWorkers = []\n  }\n\n  // Take care to not leave orphaned processes behind. See #147.\n  process.on('SIGINT', () => terminateWorkersAndMaster())\n  process.on('SIGTERM', () => terminateWorkersAndMaster())\n\n  class BlobWorker extends Worker {\n    constructor(blob: Uint8Array, options?: ThreadsWorkerOptions) {\n      super(Buffer.from(blob).toString('utf-8'), { ...options, fromSource: true })\n    }\n\n    static fromText(source: string, options?: ThreadsWorkerOptions): WorkerImplementation {\n      return new Worker(source, { ...options, fromSource: true }) as any\n    }\n  }\n\n  return {\n    blob: BlobWorker as any,\n    default: Worker as any,\n  }\n}\n\nlet implementation: ImplementationExport\n\n/**\n * Get the Node.js-specific worker implementation using `worker_threads`, lazily initializing it on first call.\n * @returns The platform-specific worker implementation export.\n */\nexport function getWorkerImplementation(): ImplementationExport {\n  if (implementation === undefined) {\n    implementation = initWorkerThreadsWorker()\n  }\n  return implementation\n}\n\n/**\n * Check whether the current code is running inside a Node.js worker thread.\n * @returns True if running in a worker thread (not the main thread), false otherwise.\n */\nexport function isWorkerRuntime() {\n  return !isMainThread\n}\n", "/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/member-ordering */\nimport type { Thread } from './thread.ts'\n\n/** Pool event type. Specifies the type of each `PoolEvent`. */\nexport enum PoolEventType {\n  initialized = 'initialized',\n  taskCanceled = 'taskCanceled',\n  taskCompleted = 'taskCompleted',\n  taskFailed = 'taskFailed',\n  taskQueued = 'taskQueued',\n  taskQueueDrained = 'taskQueueDrained',\n  taskStart = 'taskStart',\n  terminated = 'terminated',\n}\n\n/** A function that runs a task on a worker thread and returns a promise of the result. */\nexport type TaskRunFunction<ThreadType extends Thread, Return> = (worker: ThreadType) => Promise<Return>\n\n/** Pool event. Subscribe to those events using `pool.events()`. Useful for debugging. */\nexport type PoolEvent<ThreadType extends Thread>\n  = | {\n    type: PoolEventType.initialized\n    size: number\n  }\n  | {\n    type: PoolEventType.taskQueued\n    taskID: number\n  }\n  | {\n    type: PoolEventType.taskQueueDrained\n  }\n  | {\n    type: PoolEventType.taskStart\n    taskID: number\n    workerID: number\n  }\n  | {\n    type: PoolEventType.taskCompleted\n    returnValue: any\n    taskID: number\n    workerID: number\n  }\n  | {\n    type: PoolEventType.taskFailed\n    error: Error\n    taskID: number\n    workerID: number\n  }\n  | {\n    type: PoolEventType.taskCanceled\n    taskID: number\n  }\n  | {\n    type: PoolEventType.terminated\n    remainingQueue: QueuedTask<ThreadType, any>[]\n  }\n\n/** Descriptor for a worker in a pool, tracking its initialization and running tasks. */\nexport interface WorkerDescriptor<ThreadType extends Thread> {\n  init: Promise<ThreadType>\n  runningTasks: Promise<any>[]\n}\n\n/**\n * Task that has been `pool.queued()`-ed.\n */\nexport interface QueuedTask<ThreadType extends Thread, Return> {\n  /** @private */\n  id: number\n\n  /** @private */\n  run: TaskRunFunction<ThreadType, Return>\n\n  /**\n   * Queued tasks can be cancelled until the pool starts running them on a worker thread.\n   */\n  cancel(): void\n\n  /**\n   * `QueuedTask` is thenable, so you can `await` it.\n   * Resolves when the task has successfully been executed. Rejects if the task fails.\n   */\n  then: Promise<Return>['then']\n}\n", "/** Symbol key for accessing a thread's error observable. */\nexport const $errors = Symbol('thread.errors')\n/** Symbol key for accessing a thread's event observable. */\nexport const $events = Symbol('thread.events')\n/** Symbol key for accessing a thread's terminate function. */\nexport const $terminate = Symbol('thread.terminate')\n/** Symbol key for marking an object as a transferable descriptor. */\nexport const $transferable = Symbol('thread.transferable')\n/** Symbol key for accessing the underlying worker instance of a thread. */\nexport const $worker = Symbol('thread.worker')\n", "/* eslint-disable import-x/no-internal-modules */\nimport type { Observable } from 'observable-fns'\n\nimport {\n  $errors, $events, $terminate,\n} from '../symbols.ts'\nimport type { Thread as ThreadType, WorkerEvent } from '../types/master.ts'\n\nfunction fail(message: string): never {\n  throw new Error(message)\n}\n\n/** Re-exported Thread type from the master types module. */\nexport type Thread = ThreadType\n\n/** Thread utility functions. Use them to manage or inspect a `spawn()`-ed thread. */\nexport const Thread = {\n  /** Return an observable that can be used to subscribe to all errors happening in the thread. */\n  errors<ThreadT extends ThreadType>(thread: ThreadT): Observable<Error> {\n    return thread[$errors] ?? fail('Error observable not found. Make sure to pass a thread instance as returned by the spawn() promise.')\n  },\n  /** Return an observable that can be used to subscribe to internal events happening in the thread. Useful for debugging. */\n  events<ThreadT extends ThreadType>(thread: ThreadT): Observable<WorkerEvent> {\n    return thread[$events] ?? fail('Events observable not found. Make sure to pass a thread instance as returned by the spawn() promise.')\n  },\n  /** Terminate a thread. Remember to terminate every thread when you are done using it. */\n  terminate<ThreadT extends ThreadType>(thread: ThreadT) {\n    return thread[$terminate]()\n  },\n}\n"],
  "mappings": ";AAUA,OAAO,iBAAiB;AACxB;AAAA,EACE;AAAA,EAAW;AAAA,EAAY;AAAA,OAClB;;;ACVP,SAAS,YAAY;AAWd,IAAM,kBAAkB,KAAK,EAAE;;;ACT/B,IAAK,gBAAL,kBAAKA,mBAAL;AACL,EAA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