diff options
author | Allan Wang <me@allanwang.ca> | 2020-07-19 15:46:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-19 15:46:09 -0700 |
commit | 2cff5ce38e8a9fa32ee196ca911414e0b2f7e19e (patch) | |
tree | 09a756d7de8e8dcde58335c9b854119e925c03b5 /app/src/main/kotlin/com/pitchedapps/frost/kotlin/Flyweight.kt | |
parent | 7efc3d6f6f95ca9d3323009b5f66d883041a7974 (diff) | |
parent | 983a3dfa7462316df4dc01b583edf0cbe7a9d606 (diff) | |
download | frost-2cff5ce38e8a9fa32ee196ca911414e0b2f7e19e.tar.gz frost-2cff5ce38e8a9fa32ee196ca911414e0b2f7e19e.tar.bz2 frost-2cff5ce38e8a9fa32ee196ca911414e0b2f7e19e.zip |
Merge pull request #1699 from AllanWang/prefs
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.kt | 4 |
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() |