Loading packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/Demux.kt +4 −4 Original line number Diff line number Diff line Loading @@ -46,9 +46,9 @@ internal class DemuxNode<W, K, A>( branchNodeByKey.getOrPut(key) { BranchNode(key) } override fun schedule(logIndent: Int, evalScope: EvalScope) = logDuration(logIndent, "DemuxNode.schedule") { logDuration(logIndent, { "DemuxNode.schedule" }) { val upstreamResult = logDuration("upstream.getPushEvent") { logDuration({ "upstream.getPushEvent" }) { upstreamConnection.getPushEvent(currentLogIndent, evalScope) } updateEpoch(evalScope) Loading Loading @@ -147,7 +147,7 @@ internal class DemuxNode<W, K, A>( } fun getPushEvent(logIndent: Int, evalScope: EvalScope, key: K): A = logDuration(logIndent, "Demux.getPushEvent($key)") { logDuration(logIndent, { "Demux.getPushEvent($key)" }) { upstreamConnection.getPushEvent(currentLogIndent, evalScope).getValue(key) } Loading Loading @@ -193,7 +193,7 @@ internal class DemuxNode<W, K, A>( } fun schedule(logIndent: Int, evalScope: EvalScope) { logDuration(logIndent, "DemuxBranchNode($key).schedule") { logDuration(logIndent, { "DemuxBranchNode($key).schedule" }) { if (!scheduleAll(currentLogIndent, downstreamSet, evalScope)) { evalScope.scheduleDeactivation(this@BranchNode) } Loading packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/Inputs.kt +2 −2 Original line number Diff line number Diff line Loading @@ -83,7 +83,7 @@ internal class InputNode<A>( } override fun getPushEvent(logIndent: Int, evalScope: EvalScope): A = logDuration(logIndent, "Input.getPushEvent", false) { logDuration(logIndent, { "Input.getPushEvent" }, false) { transactionCache.getCurrentValue(evalScope) } } Loading Loading @@ -114,5 +114,5 @@ internal data object AlwaysNode : PushNode<Unit> { override fun removeDownstreamAndDeactivateIfNeeded(downstream: Schedulable) {} override fun getPushEvent(logIndent: Int, evalScope: EvalScope) = logDuration(logIndent, "Always.getPushEvent", false) { Unit } logDuration(logIndent, { "Always.getPushEvent" }, false) { Unit } } packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/Mux.kt +2 −2 Original line number Diff line number Diff line Loading @@ -199,9 +199,9 @@ internal sealed class MuxNode<W, K, V>(val lifecycle: MuxLifecycle<W, K, V>) : lateinit var upstream: NodeConnection<V> override fun schedule(logIndent: Int, evalScope: EvalScope) { logDuration(logIndent, "MuxBranchNode.schedule") { logDuration(logIndent, { "MuxBranchNode.schedule" }) { if (this@MuxNode is MuxPromptNode && this@MuxNode.name != null) { logLn("[${this@MuxNode}] scheduling $key") logLn({ "[${this@MuxNode}] scheduling $key" }) } upstreamData[key] = upstream.directUpstream this@MuxNode.schedule(evalScope) Loading packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/MuxDeferred.kt +12 −13 Original line number Diff line number Diff line Loading @@ -43,7 +43,6 @@ internal class MuxDeferredNode<W, K, V>( val name: String?, lifecycle: MuxLifecycle<W, K, V>, val spec: MuxActivator<W, K, V>, factory: MutableMapK.Factory<W, K>, ) : MuxNode<W, K, V>(lifecycle) { val schedulable = Schedulable.M(this) Loading @@ -52,21 +51,21 @@ internal class MuxDeferredNode<W, K, V>( override fun visit(logIndent: Int, evalScope: EvalScope) { check(epoch < evalScope.epoch) { "node unexpectedly visited multiple times in transaction" } logDuration(logIndent, "MuxDeferred[$name].visit") { logDuration(logIndent, { "MuxDeferred[$name].visit" }) { val scheduleDownstream: Boolean val result: MapK<W, K, PullNode<V>> logDuration("copying upstream data", false) { logDuration(getPrefix = { "copying upstream data" }, start = false) { scheduleDownstream = upstreamData.isNotEmpty() result = upstreamData.readOnlyCopy() upstreamData.clear() } if (name != null) { logLn("[${this@MuxDeferredNode}] result = $result") logLn { "[${this@MuxDeferredNode}] result = $result" } } val compactDownstream = depthTracker.isDirty() if (scheduleDownstream || compactDownstream) { if (compactDownstream) { logDuration("compactDownstream", false) { logDuration(getPrefix = { "compactDownstream" }, start = false) { depthTracker.applyChanges( evalScope.scheduler, downstreamSet, Loading @@ -75,9 +74,9 @@ internal class MuxDeferredNode<W, K, V>( } } if (scheduleDownstream) { logDuration("scheduleDownstream") { logDuration({ "scheduleDownstream" }) { if (name != null) { logLn("[${this@MuxDeferredNode}] scheduling") logLn { "[${this@MuxDeferredNode}] scheduling" } } transactionCache.put(evalScope, result) if (!scheduleAll(currentLogIndent, downstreamSet, evalScope)) { Loading @@ -90,10 +89,10 @@ internal class MuxDeferredNode<W, K, V>( } override fun getPushEvent(logIndent: Int, evalScope: EvalScope): MuxResult<W, K, V> = logDuration(logIndent, "MuxDeferred.getPushEvent") { logDuration(logIndent, { "MuxDeferred.getPushEvent" }) { transactionCache.getCurrentValue(evalScope).also { if (name != null) { logLn("[${this@MuxDeferredNode}] getPushEvent = $it") logLn { "[${this@MuxDeferredNode}] getPushEvent = $it" } } } } Loading @@ -119,7 +118,7 @@ internal class MuxDeferredNode<W, K, V>( // deferred to the end of this phase. fun performMove(logIndent: Int, evalScope: EvalScope) { if (name != null) { logLn(logIndent, "[${this@MuxDeferredNode}] performMove (patchData = $patchData)") logLn(logIndent) { "[${this@MuxDeferredNode}] performMove (patchData = $patchData)" } } val patch = patchData ?: return Loading Loading @@ -278,7 +277,7 @@ internal class MuxDeferredNode<W, K, V>( } fun scheduleMover(logIndent: Int, evalScope: EvalScope) { logDuration(logIndent, "MuxDeferred.scheduleMover") { logDuration(logIndent, { "MuxDeferred.scheduleMover" }) { patchData = checkNotNull(patches) { "mux mover scheduled with unset patches upstream node" } .getPushEvent(currentLogIndent, evalScope) Loading Loading @@ -307,7 +306,7 @@ internal inline fun <A> switchDeferredImplSingle( return mapImpl({ switchDeferredImpl }) { map, logIndent -> map.asSingle().getValue(Unit).getPushEvent(logIndent, this).also { if (name != null) { logLn(logIndent, "[$name] extracting single mux: $it") logLn(logIndent) { "[$name] extracting single mux: $it" } } } } Loading @@ -333,7 +332,7 @@ private class MuxDeferredActivator<W, K, V>( ): Pair<MuxNode<W, K, V>, (() -> Unit)?>? { // Initialize mux node and switched-in connections. val muxNode = MuxDeferredNode(name, lifecycle, this, storeFactory).apply { MuxDeferredNode(name, lifecycle, this).apply { initializeUpstream(evalScope, getStorage, storeFactory) // Update depth based on all initial switched-in nodes. initializeDepth() Loading packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/MuxPrompt.kt +9 −10 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ internal class MuxPromptNode<W, K, V>( val name: String?, lifecycle: MuxLifecycle<W, K, V>, private val spec: MuxActivator<W, K, V>, factory: MutableMapK.Factory<W, K>, ) : MuxNode<W, K, V>(lifecycle) { var patchData: Iterable<Map.Entry<K, Maybe<EventsImpl<V>>>>? = null Loading @@ -39,7 +38,7 @@ internal class MuxPromptNode<W, K, V>( override fun visit(logIndent: Int, evalScope: EvalScope) { check(epoch < evalScope.epoch) { "node unexpectedly visited multiple times in transaction" } logDuration(logIndent, "MuxPrompt.visit") { logDuration(logIndent, { "MuxPrompt.visit" }) { val patch: Iterable<Map.Entry<K, Maybe<EventsImpl<V>>>>? = patchData patchData = null Loading @@ -54,9 +53,9 @@ internal class MuxPromptNode<W, K, V>( depthTracker.schedule(evalScope.compactor, this@MuxPromptNode) } if (name != null) { logLn( logLn { "[${this@MuxPromptNode}] rescheduling (reschedule=$needsReschedule, depthIncrease=$depthIncreased)" ) } } schedule(evalScope) return Loading Loading @@ -104,7 +103,7 @@ internal class MuxPromptNode<W, K, V>( removes.forEach { k -> switchedIn.remove(k)?.let { branchNode: BranchNode -> if (name != null) { logLn("[${this@MuxPromptNode}] removing $k") logLn { "[${this@MuxPromptNode}] removing $k" } } val conn: NodeConnection<V> = branchNode.upstream severed.add(conn) Loading @@ -125,7 +124,7 @@ internal class MuxPromptNode<W, K, V>( // remove old and sever, if present switchedIn.remove(k)?.let { oldBranch: BranchNode -> if (name != null) { logLn("[${this@MuxPromptNode}] replacing $k") logLn { "[${this@MuxPromptNode}] replacing $k" } } val conn: NodeConnection<V> = oldBranch.upstream severed.add(conn) Loading @@ -145,7 +144,7 @@ internal class MuxPromptNode<W, K, V>( newUpstream.activate(evalScope, newBranch.schedulable)?.let { (conn, needsEval) -> newBranch.upstream = conn if (name != null) { logLn("[${this@MuxPromptNode}] switching in $k") logLn { "[${this@MuxPromptNode}] switching in $k" } } switchedIn[k] = newBranch if (needsEval) { Loading Loading @@ -197,7 +196,7 @@ internal class MuxPromptNode<W, K, V>( } override fun getPushEvent(logIndent: Int, evalScope: EvalScope): MuxResult<W, K, V> = logDuration(logIndent, "MuxPrompt.getPushEvent") { logDuration(logIndent, { "MuxPrompt.getPushEvent" }) { transactionCache.getCurrentValue(evalScope) } Loading Loading @@ -248,7 +247,7 @@ internal class MuxPromptNode<W, K, V>( lateinit var upstream: NodeConnection<Iterable<Map.Entry<K, Maybe<EventsImpl<V>>>>> override fun schedule(logIndent: Int, evalScope: EvalScope) { logDuration(logIndent, "MuxPromptPatchNode.schedule") { logDuration(logIndent, { "MuxPromptPatchNode.schedule" }) { patchData = upstream.getPushEvent(currentLogIndent, evalScope) this@MuxPromptNode.schedule(evalScope) } Loading Loading @@ -353,7 +352,7 @@ private class MuxPromptActivator<W, K, V>( ): Pair<MuxNode<W, K, V>, (() -> Unit)?>? { // Initialize mux node and switched-in connections. val movingNode = MuxPromptNode(name, lifecycle, this, storeFactory).apply { MuxPromptNode(name, lifecycle, this).apply { initializeUpstream(evalScope, getStorage, storeFactory) // Setup patches connection val patchNode = PatchNode() Loading Loading
packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/Demux.kt +4 −4 Original line number Diff line number Diff line Loading @@ -46,9 +46,9 @@ internal class DemuxNode<W, K, A>( branchNodeByKey.getOrPut(key) { BranchNode(key) } override fun schedule(logIndent: Int, evalScope: EvalScope) = logDuration(logIndent, "DemuxNode.schedule") { logDuration(logIndent, { "DemuxNode.schedule" }) { val upstreamResult = logDuration("upstream.getPushEvent") { logDuration({ "upstream.getPushEvent" }) { upstreamConnection.getPushEvent(currentLogIndent, evalScope) } updateEpoch(evalScope) Loading Loading @@ -147,7 +147,7 @@ internal class DemuxNode<W, K, A>( } fun getPushEvent(logIndent: Int, evalScope: EvalScope, key: K): A = logDuration(logIndent, "Demux.getPushEvent($key)") { logDuration(logIndent, { "Demux.getPushEvent($key)" }) { upstreamConnection.getPushEvent(currentLogIndent, evalScope).getValue(key) } Loading Loading @@ -193,7 +193,7 @@ internal class DemuxNode<W, K, A>( } fun schedule(logIndent: Int, evalScope: EvalScope) { logDuration(logIndent, "DemuxBranchNode($key).schedule") { logDuration(logIndent, { "DemuxBranchNode($key).schedule" }) { if (!scheduleAll(currentLogIndent, downstreamSet, evalScope)) { evalScope.scheduleDeactivation(this@BranchNode) } Loading
packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/Inputs.kt +2 −2 Original line number Diff line number Diff line Loading @@ -83,7 +83,7 @@ internal class InputNode<A>( } override fun getPushEvent(logIndent: Int, evalScope: EvalScope): A = logDuration(logIndent, "Input.getPushEvent", false) { logDuration(logIndent, { "Input.getPushEvent" }, false) { transactionCache.getCurrentValue(evalScope) } } Loading Loading @@ -114,5 +114,5 @@ internal data object AlwaysNode : PushNode<Unit> { override fun removeDownstreamAndDeactivateIfNeeded(downstream: Schedulable) {} override fun getPushEvent(logIndent: Int, evalScope: EvalScope) = logDuration(logIndent, "Always.getPushEvent", false) { Unit } logDuration(logIndent, { "Always.getPushEvent" }, false) { Unit } }
packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/Mux.kt +2 −2 Original line number Diff line number Diff line Loading @@ -199,9 +199,9 @@ internal sealed class MuxNode<W, K, V>(val lifecycle: MuxLifecycle<W, K, V>) : lateinit var upstream: NodeConnection<V> override fun schedule(logIndent: Int, evalScope: EvalScope) { logDuration(logIndent, "MuxBranchNode.schedule") { logDuration(logIndent, { "MuxBranchNode.schedule" }) { if (this@MuxNode is MuxPromptNode && this@MuxNode.name != null) { logLn("[${this@MuxNode}] scheduling $key") logLn({ "[${this@MuxNode}] scheduling $key" }) } upstreamData[key] = upstream.directUpstream this@MuxNode.schedule(evalScope) Loading
packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/MuxDeferred.kt +12 −13 Original line number Diff line number Diff line Loading @@ -43,7 +43,6 @@ internal class MuxDeferredNode<W, K, V>( val name: String?, lifecycle: MuxLifecycle<W, K, V>, val spec: MuxActivator<W, K, V>, factory: MutableMapK.Factory<W, K>, ) : MuxNode<W, K, V>(lifecycle) { val schedulable = Schedulable.M(this) Loading @@ -52,21 +51,21 @@ internal class MuxDeferredNode<W, K, V>( override fun visit(logIndent: Int, evalScope: EvalScope) { check(epoch < evalScope.epoch) { "node unexpectedly visited multiple times in transaction" } logDuration(logIndent, "MuxDeferred[$name].visit") { logDuration(logIndent, { "MuxDeferred[$name].visit" }) { val scheduleDownstream: Boolean val result: MapK<W, K, PullNode<V>> logDuration("copying upstream data", false) { logDuration(getPrefix = { "copying upstream data" }, start = false) { scheduleDownstream = upstreamData.isNotEmpty() result = upstreamData.readOnlyCopy() upstreamData.clear() } if (name != null) { logLn("[${this@MuxDeferredNode}] result = $result") logLn { "[${this@MuxDeferredNode}] result = $result" } } val compactDownstream = depthTracker.isDirty() if (scheduleDownstream || compactDownstream) { if (compactDownstream) { logDuration("compactDownstream", false) { logDuration(getPrefix = { "compactDownstream" }, start = false) { depthTracker.applyChanges( evalScope.scheduler, downstreamSet, Loading @@ -75,9 +74,9 @@ internal class MuxDeferredNode<W, K, V>( } } if (scheduleDownstream) { logDuration("scheduleDownstream") { logDuration({ "scheduleDownstream" }) { if (name != null) { logLn("[${this@MuxDeferredNode}] scheduling") logLn { "[${this@MuxDeferredNode}] scheduling" } } transactionCache.put(evalScope, result) if (!scheduleAll(currentLogIndent, downstreamSet, evalScope)) { Loading @@ -90,10 +89,10 @@ internal class MuxDeferredNode<W, K, V>( } override fun getPushEvent(logIndent: Int, evalScope: EvalScope): MuxResult<W, K, V> = logDuration(logIndent, "MuxDeferred.getPushEvent") { logDuration(logIndent, { "MuxDeferred.getPushEvent" }) { transactionCache.getCurrentValue(evalScope).also { if (name != null) { logLn("[${this@MuxDeferredNode}] getPushEvent = $it") logLn { "[${this@MuxDeferredNode}] getPushEvent = $it" } } } } Loading @@ -119,7 +118,7 @@ internal class MuxDeferredNode<W, K, V>( // deferred to the end of this phase. fun performMove(logIndent: Int, evalScope: EvalScope) { if (name != null) { logLn(logIndent, "[${this@MuxDeferredNode}] performMove (patchData = $patchData)") logLn(logIndent) { "[${this@MuxDeferredNode}] performMove (patchData = $patchData)" } } val patch = patchData ?: return Loading Loading @@ -278,7 +277,7 @@ internal class MuxDeferredNode<W, K, V>( } fun scheduleMover(logIndent: Int, evalScope: EvalScope) { logDuration(logIndent, "MuxDeferred.scheduleMover") { logDuration(logIndent, { "MuxDeferred.scheduleMover" }) { patchData = checkNotNull(patches) { "mux mover scheduled with unset patches upstream node" } .getPushEvent(currentLogIndent, evalScope) Loading Loading @@ -307,7 +306,7 @@ internal inline fun <A> switchDeferredImplSingle( return mapImpl({ switchDeferredImpl }) { map, logIndent -> map.asSingle().getValue(Unit).getPushEvent(logIndent, this).also { if (name != null) { logLn(logIndent, "[$name] extracting single mux: $it") logLn(logIndent) { "[$name] extracting single mux: $it" } } } } Loading @@ -333,7 +332,7 @@ private class MuxDeferredActivator<W, K, V>( ): Pair<MuxNode<W, K, V>, (() -> Unit)?>? { // Initialize mux node and switched-in connections. val muxNode = MuxDeferredNode(name, lifecycle, this, storeFactory).apply { MuxDeferredNode(name, lifecycle, this).apply { initializeUpstream(evalScope, getStorage, storeFactory) // Update depth based on all initial switched-in nodes. initializeDepth() Loading
packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/MuxPrompt.kt +9 −10 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ internal class MuxPromptNode<W, K, V>( val name: String?, lifecycle: MuxLifecycle<W, K, V>, private val spec: MuxActivator<W, K, V>, factory: MutableMapK.Factory<W, K>, ) : MuxNode<W, K, V>(lifecycle) { var patchData: Iterable<Map.Entry<K, Maybe<EventsImpl<V>>>>? = null Loading @@ -39,7 +38,7 @@ internal class MuxPromptNode<W, K, V>( override fun visit(logIndent: Int, evalScope: EvalScope) { check(epoch < evalScope.epoch) { "node unexpectedly visited multiple times in transaction" } logDuration(logIndent, "MuxPrompt.visit") { logDuration(logIndent, { "MuxPrompt.visit" }) { val patch: Iterable<Map.Entry<K, Maybe<EventsImpl<V>>>>? = patchData patchData = null Loading @@ -54,9 +53,9 @@ internal class MuxPromptNode<W, K, V>( depthTracker.schedule(evalScope.compactor, this@MuxPromptNode) } if (name != null) { logLn( logLn { "[${this@MuxPromptNode}] rescheduling (reschedule=$needsReschedule, depthIncrease=$depthIncreased)" ) } } schedule(evalScope) return Loading Loading @@ -104,7 +103,7 @@ internal class MuxPromptNode<W, K, V>( removes.forEach { k -> switchedIn.remove(k)?.let { branchNode: BranchNode -> if (name != null) { logLn("[${this@MuxPromptNode}] removing $k") logLn { "[${this@MuxPromptNode}] removing $k" } } val conn: NodeConnection<V> = branchNode.upstream severed.add(conn) Loading @@ -125,7 +124,7 @@ internal class MuxPromptNode<W, K, V>( // remove old and sever, if present switchedIn.remove(k)?.let { oldBranch: BranchNode -> if (name != null) { logLn("[${this@MuxPromptNode}] replacing $k") logLn { "[${this@MuxPromptNode}] replacing $k" } } val conn: NodeConnection<V> = oldBranch.upstream severed.add(conn) Loading @@ -145,7 +144,7 @@ internal class MuxPromptNode<W, K, V>( newUpstream.activate(evalScope, newBranch.schedulable)?.let { (conn, needsEval) -> newBranch.upstream = conn if (name != null) { logLn("[${this@MuxPromptNode}] switching in $k") logLn { "[${this@MuxPromptNode}] switching in $k" } } switchedIn[k] = newBranch if (needsEval) { Loading Loading @@ -197,7 +196,7 @@ internal class MuxPromptNode<W, K, V>( } override fun getPushEvent(logIndent: Int, evalScope: EvalScope): MuxResult<W, K, V> = logDuration(logIndent, "MuxPrompt.getPushEvent") { logDuration(logIndent, { "MuxPrompt.getPushEvent" }) { transactionCache.getCurrentValue(evalScope) } Loading Loading @@ -248,7 +247,7 @@ internal class MuxPromptNode<W, K, V>( lateinit var upstream: NodeConnection<Iterable<Map.Entry<K, Maybe<EventsImpl<V>>>>> override fun schedule(logIndent: Int, evalScope: EvalScope) { logDuration(logIndent, "MuxPromptPatchNode.schedule") { logDuration(logIndent, { "MuxPromptPatchNode.schedule" }) { patchData = upstream.getPushEvent(currentLogIndent, evalScope) this@MuxPromptNode.schedule(evalScope) } Loading Loading @@ -353,7 +352,7 @@ private class MuxPromptActivator<W, K, V>( ): Pair<MuxNode<W, K, V>, (() -> Unit)?>? { // Initialize mux node and switched-in connections. val movingNode = MuxPromptNode(name, lifecycle, this, storeFactory).apply { MuxPromptNode(name, lifecycle, this).apply { initializeUpstream(evalScope, getStorage, storeFactory) // Setup patches connection val patchNode = PatchNode() Loading