Acquires the lock, waiting if necessary until it is available.
Optional
signal: null | AbortSignalAn optional AbortSignal to cancel the acquire operation.
A promise that resolves to a function that releases the lock.
Releases the lock.
Acquires the lock, executes the callback, and releases the lock.
Optional
signal: null | AbortSignalAn optional AbortSignal to cancel the acquire operation.
The result of the callback.
A mutex is a synchronization primitive that can be used to protect shared resources from concurrent access. It is similar to a semaphore with a value of 1.
A mutex has two states: locked and unlocked. When a mutex is locked, other I/O operations that attempt to lock the mutex will wait until the mutex is unlocked. When a mutex is unlocked, it can be locked by an I/O operation.