A lock returned by Semaphore.acquire. Call SemaphoreLock.release to free the slot and allow the next waiting operation to proceed.
const semaphore = new Semaphore(3);const lock = await semaphore.acquire();try { // ... do concurrent-limited work ...} finally { lock.release(); // always release, even on error} Copy
const semaphore = new Semaphore(3);const lock = await semaphore.acquire();try { // ... do concurrent-limited work ...} finally { lock.release(); // always release, even on error}
Creates a new lock instance.
A callback invoked once when the lock is released.
Releases the lock and allows the next waiting operation to proceed. Subsequent calls are no-ops; the lock can only be released once.
A lock returned by Semaphore.acquire. Call SemaphoreLock.release to free the slot and allow the next waiting operation to proceed.
Example