Skip to content

Mutex.runExclusive method

Mutex › runExclusive

Runs a function while holding the lock, freeing 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 the lock. It does not interrupt operation once it has started.

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