-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed6f3a3
commit cbedc26
Showing
4 changed files
with
70 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,10 @@ import type { | |
ServerCrypto, | ||
} from './types'; | ||
import type { Connection } from '@/native'; | ||
import type { LockBox, RWLockWriter } from '@matrixai/async-locks'; | ||
import dns from 'dns'; | ||
import { IPv4, IPv6, Validator } from 'ip-num'; | ||
import { Monitor } from '@matrixai/async-locks'; | ||
import QUICConnectionId from './QUICConnectionId'; | ||
import * as errors from './errors'; | ||
|
||
|
@@ -428,6 +430,19 @@ function streamStats( | |
`; | ||
} | ||
|
||
async function withMonitor<T>( | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
CMCDragonkai
Member
|
||
mon: Monitor<RWLockWriter> | undefined, | ||
lockBox: LockBox<RWLockWriter>, | ||
lockConstructor: { new (): RWLockWriter }, | ||
fun: (mon: Monitor<RWLockWriter>) => Promise<T>, | ||
locksPending?: Map<string, { count: number }>, | ||
): Promise<T> { | ||
const _mon = mon ?? new Monitor(lockBox, lockConstructor, locksPending); | ||
const result = await fun(_mon); | ||
if (mon != null) await _mon.unlockAll(); | ||
return result; | ||
} | ||
|
||
export { | ||
isIPv4, | ||
isIPv6, | ||
|
@@ -455,4 +470,5 @@ export { | |
validateToken, | ||
sleep, | ||
streamStats, | ||
withMonitor, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This should be implemented with the
monitor
resource acquisition.