Page MenuHomeGitPull.it

D210.1770959676.diff
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

D210.1770959676.diff

diff --git a/app/src/main/java/it/reyboz/bustorino/backend/mato/MQTTMatoClient.kt b/app/src/main/java/it/reyboz/bustorino/backend/mato/MQTTMatoClient.kt
--- a/app/src/main/java/it/reyboz/bustorino/backend/mato/MQTTMatoClient.kt
+++ b/app/src/main/java/it/reyboz/bustorino/backend/mato/MQTTMatoClient.kt
@@ -375,13 +375,20 @@
val currentTimeStamp = makeUnixTimestamp()
var c = 0
positionsLock.withLock{
- for ((k, manyp) in currentPositions.entries) {
- for ((t, p) in manyp.entries) {
+ for ((k, posByVeh) in currentPositions) {
+ /*for (t in posByVeh.keys.toList()) { // iterate over snapshot to avoid modification error
+ val p = posByVeh[t] ?: continue
if (currentTimeStamp - p.timestamp > timeMins * 60) {
- manyp.remove(t)
+ posByVeh.remove(t)
c += 1
}
}
+ */
+ c+=posByVeh.entries.removeIf{ el ->
+ currentTimeStamp - el.value.timestamp > timeMins * 60
+ }.let {
+ if(it) 1 else 0
+ }
}
}
Log.d(DEBUG_TAG, "Removed $c positions older than $timeMins minutes")

File Metadata

Mime Type
text/plain
Expires
Fri, Feb 13, 06:14 (14 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1622365
Default Alt Text
D210.1770959676.diff (1 KB)

Event Timeline