UNPKG

async-monitor

Version:

Provides a mechanism that synchronizes access to objects.

15 lines (14 loc) 672 B
import { type MapKey } from "./type/map"; import { type CriticalSection } from "./async-monitor/critical-section"; /** * Acquires an exclusive lock on the specified key. */ export declare function enter<T>(key: MapKey, scope: (criticalSection: CriticalSection) => Promise<T> | T): Promise<T>; /** * Attempts, for the specified amount of time, to acquire an exclusive lock on the specified key. */ export declare function tryEnter<T>(key: MapKey, timeout: number, scope: (criticalSection: CriticalSection | null) => Promise<T> | T): Promise<T>; /** * Attempts to get the current CriticalSection */ export declare function tryGet(key: MapKey): CriticalSection | null;