()
| 366 | private resolverQueue: (() => void)[] = []; |
| 367 | |
| 368 | lock() { |
| 369 | if (!this.locked) { |
| 370 | // Fast path |
| 371 | this.locked = true; |
| 372 | return this.createLock(false, null); |
| 373 | } |
| 374 | |
| 375 | const { promise, resolve } = promiseWithResolvers(); |
| 376 | this.resolverQueue.push(resolve); |
| 377 | |
| 378 | return this.createLock(true, promise); |
| 379 | } |
| 380 | |
| 381 | private createLock(pending: boolean, ready: Promise<void> | null): AsyncMutexLock { |
| 382 | let released = false; |
no test coverage detected