Skip to content

Commit

Permalink
PIA-1187: Make regions result map synchronized
Browse files Browse the repository at this point in the history
  • Loading branch information
kp-juan-docal committed Jan 12, 2024
1 parent 937a44e commit b32d46d
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ internal actual class PingPerformer : CoroutineScope {
callback: (result: Map<String, List<Pair<String, Long>>>) -> Unit
) {
async {
val result = mutableMapOf<String, List<Pair<String, Long>>>()
val syncResult =
Collections.synchronizedMap(mutableMapOf<String, List<Pair<String, Long>>>())
val requests: MutableList<Job> = mutableListOf()
for ((region, endpointsInRegion) in endpoints) {
val syncRegionEndpointsResults =
Expand All @@ -59,12 +60,12 @@ internal actual class PingPerformer : CoroutineScope {
REGIONS_PING_TIMEOUT.toLong()
} ?: latency
syncRegionEndpointsResults.add(Pair(it, latency))
result[region] = syncRegionEndpointsResults
syncResult[region] = syncRegionEndpointsResults
})
}
}
requests.joinAll()
launch(Dispatchers.Main) { callback(result) }
launch(Dispatchers.Main) { callback(syncResult) }
}
}

Expand Down

0 comments on commit b32d46d

Please sign in to comment.