Skip to content

Commit 9a2c0e3

Browse files
committed
check semaphore
1 parent 2875db4 commit 9a2c0e3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/wrapper/CxWrapper.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ import {Semaphore} from "async-mutex";
1111

1212

1313
type ParamTypeMap = Map<CxParamType, string>;
14+
const semaphore = new Semaphore(1); // Semaphore with 1 slot
15+
1416

1517
export class CxWrapper {
1618
private static instances =new Map<string, CxWrapper>(); // Multiton pattern
17-
private static semaphore = new Semaphore(1); // Semaphore with 1 slot
1819
config: CxConfig;
1920
cxInstaller: CxInstaller;
2021
private constructor(cxScanConfig: CxConfig, logFilePath?: string) {
@@ -50,7 +51,7 @@ export class CxWrapper {
5051
}
5152

5253
static async getInstance(cxScanConfig: CxConfig, logFilePath: string): Promise<CxWrapper> {
53-
const [, release] = await this.semaphore.acquire();
54+
const [, release] = await semaphore.acquire();
5455
const key = this.generateKey(cxScanConfig, logFilePath);
5556
let wrapper = CxWrapper.instances.get(key);
5657
if (!wrapper) {

0 commit comments

Comments
 (0)