* Execute a function while holding the lock
(fn: () => Promise<T> | T)
| 738 | * Execute a function while holding the lock |
| 739 | */ |
| 740 | async withLock<T>(fn: () => Promise<T> | T): Promise<T> { |
| 741 | const release = await this.acquire(); |
| 742 | try { |
| 743 | return await fn(); |
| 744 | } finally { |
| 745 | release(); |
| 746 | } |
| 747 | } |
| 748 | |
| 749 | /** |
| 750 | * Check if the lock is currently held |
no test coverage detected