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