aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/kotlin/Flyweight.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2020-07-18 20:02:06 -0700
committerAllan Wang <me@allanwang.ca>2020-07-18 20:02:06 -0700
commit5eb18e7464ceb5b7029912498ab02cf9b2556903 (patch)
tree32d184c7ef27eeaf5f6639bc9300d5cb822d372a /app/src/main/kotlin/com/pitchedapps/frost/kotlin/Flyweight.kt
parent0fc1e0c9c13c6cf551f985c3617f1bcaf8f62aa6 (diff)
downloadfrost-5eb18e7464ceb5b7029912498ab02cf9b2556903.tar.gz
frost-5eb18e7464ceb5b7029912498ab02cf9b2556903.tar.bz2
frost-5eb18e7464ceb5b7029912498ab02cf9b2556903.zip
Split prefs into segments
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/kotlin/Flyweight.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/kotlin/Flyweight.kt4
1 files changed, 4 insertions, 0 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/kotlin/Flyweight.kt b/app/src/main/kotlin/com/pitchedapps/frost/kotlin/Flyweight.kt
index 55a4c372..854dcf28 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/kotlin/Flyweight.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/kotlin/Flyweight.kt
@@ -45,15 +45,19 @@ class Flyweight<K, V>(
// Receives a key and a pending request
private val actionChannel = Channel<Pair<K, CompletableDeferred<V>>>(Channel.UNLIMITED)
+
// Receives a key to invalidate the associated value
private val invalidatorChannel = Channel<K>(Channel.UNLIMITED)
+
// Receives a key and the resulting value
private val receiverChannel = Channel<Pair<K, Result<V>>>(Channel.UNLIMITED)
// Keeps track of keys and associated update times
private val conditionMap: MutableMap<K, Long> = mutableMapOf()
+
// Keeps track of keys and associated values
private val resultMap: MutableMap<K, Result<V>> = mutableMapOf()
+
// Keeps track of unfulfilled actions
// Note that the explicit type is very important here. See https://youtrack.jetbrains.net/issue/KT-18053
private val pendingMap: MutableMap<K, MutableList<CompletableDeferred<V>>> = ConcurrentHashMap()