* Execute a function while holding the lock
(fn: () => T)
| 607 | * Execute a function while holding the lock |
| 608 | */ |
| 609 | withLock<T>(fn: () => T): T { |
| 610 | this.acquire(); |
| 611 | try { |
| 612 | return fn(); |
| 613 | } finally { |
| 614 | this.release(); |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | /** |
| 619 | * Execute an async function while holding the lock |