Mutex, the mutex implementation for async operations
5.15.0
const mut = new Mutex() async call_api(payload: any) { const release = await mut.acquire() try { // ... // this block, will be executed exclusively } finally { release() // release the mutex }} Copy
const mut = new Mutex() async call_api(payload: any) { const release = await mut.acquire() try { // ... // this block, will be executed exclusively } finally { release() // release the mutex }}
acquire a permit from sem
wait before timeout, if not set, will wait forever
release function, which used for release a permit to sem
run an async function with sem limit
async runner function
wait timeout before wait
Mutex, the mutex implementation for async operations