@@ -72,10 +72,10 @@ class UserDecisionRegistry private constructor(
7272 // First decision for this certificate, add to map and show UI
7373 pendingDecisions[cert] = mutableListOf (cont)
7474
75- scope.launch {
75+ scope.launch { // launch asynchronously (scoped)
7676 val userDecision = getUserDecision(cert) // suspends until user decision is made
7777
78- // resume all coroutines that are waiting for a decision
78+ // register decision and resume all coroutines that are waiting for the decision
7979 resumeOnUserDecision(cert, userDecision)
8080 }
8181 }
@@ -94,15 +94,20 @@ class UserDecisionRegistry private constructor(
9494
9595 // continue work that's waiting for decisions
9696 synchronized(pendingDecisions) {
97- pendingDecisions[cert]?.iterator()?.let { iter ->
97+ pendingDecisions[cert]?.let { pendingDecisionsForCert ->
98+ // go through all Continuations that are waiting for a decision about this certificate
99+ val iter = pendingDecisionsForCert.iterator()
98100 while (iter.hasNext()) {
101+ // resume work with the now known trustworthiness
99102 iter.next().resume(trusted)
103+
104+ // remove current Continuation (that hast just been resumed) from list
100105 iter.remove()
101106 }
102- }
103107
104- // remove certificate from pendingDecisions so UI can be shown again in future
105- pendingDecisions.remove(cert)
108+ // remove certificate from pendingDecisions so UI can be shown again in future
109+ pendingDecisions - = cert
110+ }
106111 }
107112 }
108113
0 commit comments