chore: v3.1.24
[poolifier.git] / src / pools / worker.ts
index 05f6606edde672db081d9f392e9584ebc7a917f7..ee54c6acc3f17216361f3c20b55b61f74376f260 100644 (file)
@@ -1,5 +1,6 @@
-import type { MessageChannel, WorkerOptions } from 'node:worker_threads'
 import type { EventEmitter } from 'node:events'
+import type { MessageChannel, WorkerOptions } from 'node:worker_threads'
+
 import type { CircularArray } from '../circular-array.js'
 import type { Task } from '../utility-types.js'
 
@@ -235,6 +236,12 @@ export interface IWorker extends EventEmitter {
    * @param handler - The event handler.
    */
   readonly once: (event: string, handler: EventHandler<this>) => this
+  /**
+   * Calling `unref()` on a worker allows the thread to exit if this is the only
+   * active handle in the event system. If the worker is already `unref()`ed calling`unref()` again has no effect.
+   * @since v10.5.0
+   */
+  readonly unref?: () => void
   /**
    * Stop all JavaScript execution in the worker thread as soon as possible.
    * Returns a Promise for the exit code that is fulfilled when the `'exit' event` is emitted.