WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/kotlinx-coroutines-core/src/test/kotlin/kotlinx/coroutines/experimental/channels/BroadcastChannelMultiReceiveStressTest.kt
+18-8Lines changed: 18 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -60,8 +60,10 @@ class BroadcastChannelMultiReceiveStressTest(
60
60
val ctx = pool + coroutineContext[Job]!!
61
61
val sender =
62
62
launch(context = ctx +CoroutineName("Sender")) {
63
+
var i =0
63
64
while (isActive) {
64
-
broadcast.send(sentTotal.incrementAndGet())
65
+
broadcast.send(++i)
66
+
sentTotal.set(i) // set sentTotal only if `send` was not cancelled
65
67
}
66
68
}
67
69
val receivers = mutableListOf<Job>()
@@ -84,7 +86,7 @@ class BroadcastChannelMultiReceiveStressTest(
84
86
}
85
87
}
86
88
// wait a sec
87
-
delay(1000)
89
+
delay(100)
88
90
// print progress
89
91
println("${sec +1}: Sent ${sentTotal.get()}, received ${receivedTotal.get()}, receivers=${receivers.size}")
90
92
}
@@ -93,13 +95,21 @@ class BroadcastChannelMultiReceiveStressTest(
93
95
val total = sentTotal.get()
94
96
println(" Sent $total events, waiting for receivers")
0 commit comments