UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

32 lines (31 loc) 717 B
import { Semaphore } from "./Semaphore"; /** * Mutex, the mutex implementation for async operations */ export declare class Mutex extends Semaphore { /** * Mutex, the mutex implementation for async operations * * @since 5.15.0 * @category Functional * @example * * ```ts * 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 * } * } * * ``` * */ constructor(defaultAcquireTimeout?: number); } export default Mutex;