aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/vendor/async-mutex/interface.ts
blob: 736b338e509dbe6f886be29641997d1f588da850 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
export interface MutexInterface {
  acquire(priority?: number): Promise<MutexInterface.Releaser>;

  runExclusive<T>(
    callback: MutexInterface.Worker<T>,
    priority?: number
  ): Promise<T>;

  waitForUnlock(priority?: number): Promise<void>;

  isLocked(): boolean;

  release(): void;

  cancel(): void;
}

export namespace MutexInterface {
  export interface Releaser {
    (): void;
  }

  export interface Worker<T> {
    (): Promise<T> | T;
  }
}