import CancellationToken from './Promises/CancellationToken'; /** Interface for a lock */ export interface ILock { /** Releases the lock */ releaseAsync(): Promise; } declare class Lock implements ILock { #private; constructor(releaseAsync: (cancellationToken: CancellationToken) => Promise); releaseAsync(cancellationToken?: CancellationToken): Promise; } /** * Creates a mutex that when acquired will return a lock that needs to be released * before any waiting code can be run. */ export default class Mutex { #private; /** Acquires a lock on this mutex. Only one lock can be kept at a time; calling multiple times will create dependent locks */ acquireAsync(cancellationToken?: CancellationToken): Promise; /** * Returns a promise that can be awaited until the lock is released. * If there is no lock the promise is resolved immediately. */ waitAsync(cancellationToken?: CancellationToken): Promise; } /** * Locks on the provided mutex until the provided func is complete, then returning a value if any. * @param mutex * @param func */ export declare function lockAsync(mutex: Mutex, func: () => T, cancellationToken?: CancellationToken): Promise; export declare function lockAsync(mutex: Mutex, func: () => Promise, cancellationToken?: CancellationToken): Promise; export {};