scoop:scoop.http.asyncio:0.1.0
src/http2_driver.scoop
Selected production source · src/http2_driver.scoop
1
package scoop.http.asyncio3
internal fun driveH2(state: H2State) {4
val start =5
state.lock.withLock {6
if (state.driving)7
false8
else {9
state.driving = true;10
true11
}12
}13
if (!start)14
return15
while (true) {16
val actions = ArrayList<() -> Unit>()17
val again =18
state.lock.withLock {19
var changed = false20
if (!state.closed) {21
if (state.closing)22
changed = advanceH2Close(state, actions)23
else {24
try {25
state.ownerJob?.ensureActive()26
changed = receiveH2Events(state, actions)27
if (!state.closing)28
changed = checkH2Idle(state, actions) || changed29
if (!state.closing)30
changed = finishH2Operations(state, actions) || changed31
if (!state.closing)32
changed = reconcileH2Idle(state, actions) || changed33
if (!state.closing)34
changed = planH2Transfers(state, actions) || changed35
if (!state.closing)36
changed = receiveH2Events(state, actions) || changed37
} catch (error: Throwable) {38
terminateH2(state, error);39
changed = true40
}41
}42
}43
if (!changed && actions.size == 0L)44
state.driving = false45
changed || actions.size != 0L46
}47
if (!again)48
return49
for (action in actions)50
action()51
}52
}