refactor: cleanup async lock acquire()
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 29 May 2023 12:44:23 +0000 (14:44 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 29 May 2023 12:44:23 +0000 (14:44 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/utils/AsyncLock.ts

index 229086fef1e8d2b45b9ae8f39ca77b867af0e2d5..cf0443b29c30268e0326ec5c2c8134b4bc284315 100644 (file)
@@ -19,11 +19,11 @@ export class AsyncLock {
     const asyncLock = AsyncLock.getAsyncLock(type);
     if (!asyncLock.acquired) {
       asyncLock.acquired = true;
-    } else {
-      return new Promise((resolve) => {
-        asyncLock.resolveQueue.push(resolve);
-      });
+      return;
     }
+    return new Promise((resolve) => {
+      asyncLock.resolveQueue.push(resolve);
+    });
   }
 
   public static async release(type: AsyncLockType): Promise<void> {