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