* Execute a function while holding the lock
(fn: () => T)
| 633 | * Execute a function while holding the lock |
| 634 | */ |
| 635 | withLock<T>(fn: () => T): T { |
| 636 | this.acquire(); |
| 637 | try { |
| 638 | return fn(); |
| 639 | } finally { |
| 640 | this.release(); |
| 641 | } |
| 642 | } |
| 643 | |
| 644 | /** |
| 645 | * Execute an async function while holding the lock |