From 30e42fb1db04e3f76f6cfa85f582af350737cd64 Mon Sep 17 00:00:00 2001 From: havelessbemore Date: Fri, 10 May 2024 08:06:52 -0400 Subject: [PATCH] Add ownsLock / ownsSharedLock properties --- src/types/basicLockable.d.ts | 7 ++++++- src/types/sharedLockable.d.ts | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/types/basicLockable.d.ts b/src/types/basicLockable.d.ts index 7c97899..d0c2304 100644 --- a/src/types/basicLockable.d.ts +++ b/src/types/basicLockable.d.ts @@ -4,7 +4,12 @@ */ export interface BasicLockable { /** - * Blocks until a lock can be acquired for the current agent. + * Indicates whether the current agent owns the lock. + */ + ownsLock: readonly boolean; + + /** + * Blocks until the lock can be acquired for the current agent. * If an exception is thrown, no lock is acquired. */ lock(): Promise; diff --git a/src/types/sharedLockable.d.ts b/src/types/sharedLockable.d.ts index 3c36f34..d8385f9 100644 --- a/src/types/sharedLockable.d.ts +++ b/src/types/sharedLockable.d.ts @@ -2,6 +2,11 @@ * Provides shared blocking semantics for agents (i.e. main thread, workers). */ export interface SharedLockable { + /** + * Indicates whether the current agent owns a shared lock. + */ + ownsSharedLock: readonly boolean; + /** * Blocks until a shared lock can be acquired for the current * agent. If an exception is thrown, no lock is acquired.