* Execute a function while holding the lock
(fn: () => Promise<T> | T)
| 712 | * Execute a function while holding the lock |
| 713 | */ |
| 714 | async withLock<T>(fn: () => Promise<T> | T): Promise<T> { |
| 715 | const release = await this.acquire(); |
| 716 | try { |
| 717 | return await fn(); |
| 718 | } finally { |
| 719 | release(); |
| 720 | } |
| 721 | } |
| 722 | |
| 723 | /** |
| 724 | * Check if the lock is currently held |
no test coverage detected