@neutrium/utilities - v3.1.0
    Preparing search index...

    Class SerialOperationQueue

    Serializes synchronous and asynchronous operations in submission order. Each result settles independently; failures do not prevent subsequent work. Disposal immediately closes admission, then runs cleanup once after accepted work.

    Operations start in a Promise microtask, never inline. Return or await all work that must be serialized. Do not await work queued behind the current operation on this same queue: that creates a dependency cycle.

    Index
    • get closed(): boolean

      True as soon as disposal is requested, even while accepted work is still running.

      Returns boolean

    • Close admission immediately and enqueue optional cleanup after accepted work.

      Parameters

      • operation: () => void | PromiseLike<void> = ...

        Cleanup callback. Only the first accepted cleanup is used.

      Returns Promise<void>

      The same Promise on every valid call, including after cleanup fails. Cleanup is never retried. Invalid callbacks reject even after disposal has been requested; an invalid initial callback does not close the queue.

    • Wait for work accepted before this call to settle, without closing admission.

      Returns Promise<void>

      A fulfilled Promise after that snapshot of work finishes, even if an operation failed. Work submitted later is excluded. Inspect individual result Promises, including dispose(), to observe failures.

    • Submit an operation and receive its own result or rejection.

      Type Parameters

      • T

      Parameters

      • operation: () => T

        Callback returning a value, Promise or PromiseLike value.

      Returns Promise<Awaited<T>>

      A Promise that adopts the callback's result. Closed queues and invalid callbacks return rejected Promises without invoking or admitting the callback.