import { isObject , isFunction , isDefined } from "@esfx/internal-guards" ; export interface Lockable { param ms returns [ Lockable . lock ] ( ms ? ) : boolean ; returns [ Lockable . tryLock ] ? ( ) : boolean ; returns [ Lockable . unlock ] ( ) : boolean ; } export namespace Lockable { export const lock = Symbol . for ( "@esfx/thread-lockable:Lockable.lock" ) ; export const tryLock = Symbol . for ( "@esfx/thread-lockable:Lockable.tryLock" ) ; export const unlock = Symbol . for ( "@esfx/thread-lockable:Lockable.unlock" ) ; export const name = "Lockable" ; export function hasInstance ( value ) { return isObject ( value ) && Lockable . lock in value && Lockable . unlock in value && ( ! ( Lockable . tryLock in value ) || ! isDefined ( Lockable . tryLock ) || isFunction ( Lockable . tryLock ) ) ; } }