// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
-import Queue from 'mnemonist/queue.js'
+import { Queue } from 'mnemonist'
import { Constants } from './Constants.js'
private constructor () {
this.acquired = false
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
this.resolveQueue = new Queue<ResolveType>()
}
return
}
await new Promise<void>((resolve) => {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
asyncLock.resolveQueue.enqueue(resolve)
})
}
private static async release (type: AsyncLockType): Promise<void> {
const asyncLock = AsyncLock.getAsyncLock(type)
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (asyncLock.resolveQueue.size === 0 && asyncLock.acquired) {
asyncLock.acquired = false
return
}
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const queuedResolve = asyncLock.resolveQueue.dequeue()!
await new Promise<void>((resolve) => {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
queuedResolve()
resolve()
})