Skip to content

Semaphore.runExclusive method

Semaphore › runExclusive

Runs a function while holding a permit, releasing it when the function settles.

Signature:

runExclusive(operation: () => Promisable<T>, abortSignal?: AbortSignal | undefined): Promise<T>

Parameters:

ParameterTypeDescription
operation() => Promisable<T>The function to run.
abortSignal?AbortSignal | undefinedCancels the wait for a permit. It does not interrupt operation once it has started.

Returns: Promise<T> — A Promise that resolves with the function's result.