Skip to content

Commit fe64780

Browse files
committed
~ Added comment on how freeSlot can resume coroutines
1 parent 25e08d4 commit fe64780

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

kotlinx-coroutines-core/common/src/flow/internal/AbstractSharedFlow.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ internal abstract class AbstractSharedFlow<S : AbstractSharedFlowSlot<*>> : Sync
8282
if (nCollectors == 0) nextIndex = 0
8383
(slot as AbstractSharedFlowSlot<Any>).freeLocked(this)
8484
}
85-
// Resume suspended coroutines
85+
/*
86+
Resume suspended coroutines.
87+
This can happens when the subscriber that was freed was a slow one and was holding up buffer.
88+
When this subscriber was freed, previously queued emitted can now wake up and are resumed here.
89+
*/
8690
for (cont in resumes) cont?.resume(Unit)
8791
// decrement subscription count
8892
subscriptionCount?.increment(-1)

0 commit comments

Comments
 (0)