* Execute a function while holding the lock
(fn: () => Promise<T> | T)
| 403 | * Execute a function while holding the lock |
| 404 | */ |
| 405 | async withLock<T>(fn: () => Promise<T> | T): Promise<T> { |
| 406 | const release = await this.acquire(); |
| 407 | try { |
| 408 | return await fn(); |
| 409 | } finally { |
| 410 | release(); |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | /** |
| 415 | * Check if the lock is currently held |
no test coverage detected