repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build(deps-dev): apply updates
[e-mobility-charging-stations-simulator.git]
/
src
/
utils
/
AsyncLock.ts
diff --git
a/src/utils/AsyncLock.ts
b/src/utils/AsyncLock.ts
index d11419723c010fef52739b53f4ce86009103cb08..f6b793a60748beaa8454fdb80e13510553a25898 100644
(file)
--- a/
src/utils/AsyncLock.ts
+++ b/
src/utils/AsyncLock.ts
@@
-1,12
+1,12
@@
-// Partial Copyright Jerome Benoit. 2021-202
3
. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-202
4
. All Rights Reserved.
-import
Queue from 'mnemonist/queue.js
'
+import
{ Queue } from 'mnemonist
'
import { Constants } from './Constants.js'
export enum AsyncLockType {
configuration = 'configuration',
import { Constants } from './Constants.js'
export enum AsyncLockType {
configuration = 'configuration',
- performance = 'performance'
,
+ performance = 'performance'
}
type ResolveType = (value: void | PromiseLike<void>) => void
}
type ResolveType = (value: void | PromiseLike<void>) => void
@@
-18,7
+18,6
@@
export class AsyncLock {
private constructor () {
this.acquired = false
private constructor () {
this.acquired = false
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
this.resolveQueue = new Queue<ResolveType>()
}
this.resolveQueue = new Queue<ResolveType>()
}
@@
-36,23
+35,20
@@
export class AsyncLock {
asyncLock.acquired = true
return
}
asyncLock.acquired = true
return
}
- await new Promise<void>((resolve) => {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
+ await new Promise<void>(resolve => {
asyncLock.resolveQueue.enqueue(resolve)
})
}
private static async release (type: AsyncLockType): Promise<void> {
const asyncLock = AsyncLock.getAsyncLock(type)
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
}
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()!
const queuedResolve = asyncLock.resolveQueue.dequeue()!
- await new Promise<void>((resolve) => {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
+ await new Promise<void>(resolve => {
queuedResolve()
resolve()
})
queuedResolve()
resolve()
})