TeaSpeak-Client/imports/shared-app/Mutex.d.ts
2021-04-19 20:27:12 +02:00

19 lines
567 B
TypeScript

export declare class Mutex<T> {
private value;
private taskExecuting;
private taskQueue;
private freeListener;
constructor(value: T);
isFree(): boolean;
awaitFree(): Promise<void>;
execute<R>(callback: (value: T, setValue: (newValue: T) => void) => R | Promise<R>): Promise<R>;
tryExecute<R>(callback: (value: T, setValue: (newValue: T) => void) => R | Promise<R>): Promise<{
status: "success";
result: R;
} | {
status: "would-block";
}>;
private executeNextTask;
private triggerFinished;
}