Create an independent queue.
Error message for work submitted after disposal is requested.
True as soon as disposal is requested, even while accepted work is still running.
Close admission immediately and enqueue optional cleanup after accepted work.
Cleanup callback. Only the first accepted cleanup is used.
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.
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.
Callback returning a value, Promise or PromiseLike value.
A Promise that adopts the callback's result. Closed queues and invalid callbacks return rejected Promises without invoking or admitting the callback.
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.
Remarks
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.