Monitor usage in QUICConnection
#48
Labels
development
Standard development
r&d:polykey:core activity 4
End to End Networking behind Consumer NAT Devices
Specification
The monitor is necessary to enable re-entrancy within a call graph of certain operations like
send
andrecv
inQUICConnection
while also ensuring mutual exclusion between different call graphs.However, the
monitor
currently as used isn't using themonitor
resource acquisition function that I had earlier created in MatrixAI/js-contexts#2.I just pushed out
1.2.0
ofjs-contexts
which exposesmonitor
as aResourceAcquire
.You can remove the
utils.withMonitor
in favour of doing something like this:Additionally in the beginning during
QUICConnection.createQUICConnection
, you don't actually need to setup so much just to do the initialrecv
andsend
under afterstart
.Also you don't need to lock anything in that scenario cause nothing is actually going to be able to intercept those calls during
createQUICConnection
because nothing else has reference to theQUICConnection
instance.I think it would far more clearer to write it in a way where your initial
recv
andsend
is just part of theasync start
method. Just put yourrecv
andsend
calls within that. It does not appear thatstart
is called anywhere else, so it can just be part ofQUICConnection.start
.Finally both
send
andrecv
should havemon?: Monitor
. Both should then use thewithF
pattern above in case the monitor doesn't yet exist.Additional context
Tasks
1.2.0
ofjs-contexts
to get access to themonitor
function.utils.withMonitor
withmonitor
withF
pattern to create monitor for bothsend
andrecv
recv
andsend
withinQUICConnection.start
, since that would be much clearer. You can still setup a monitor, but no locking is really required at that point.QUICServer
, why is there an additional separation ofconnectionProm
? This is unnecessary.The text was updated successfully, but these errors were encountered: