@@ -24,10 +24,11 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater
2424import java.util.concurrent.atomic.AtomicReferenceFieldUpdater
2525
2626/* *
27- * Broadcasts the most recently sent value (aka [value]) to all [open] subscribers.
27+ * Broadcasts the most recently sent element (aka [value]) to all [open] subscribers.
2828 *
2929 * Back-to-send sent elements are _conflated_ -- only the the most recently sent value is received,
3030 * while previously sent elements **are lost**.
31+ * Every subscriber immediately receives the most recently sent element.
3132 * Sender to this broadcast channel never suspends and [offer] always returns `true`.
3233 *
3334 * A secondary constructor can be used to create an instance of this class that already holds a value.
@@ -36,12 +37,12 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater
3637 * [opening][open] and [closing][SubscriptionReceiveChannel.close] subscription takes O(N) time, where N is the
3738 * number of subscribers.
3839 */
39- public class ValueBroadcastChannel <E >() : BroadcastChannel<E> {
40+ public class ConflatedBroadcastChannel <E >() : BroadcastChannel<E> {
4041 /* *
4142 * Creates an instance of this class that already holds a value.
4243 *
4344 * It is as a shortcut to creating an instance with a default constructor and
44- * immediately sending a value : `ValueBroadcastChannel ().apply { offer(value) }`.
45+ * immediately sending an element : `ConflatedBroadcastChannel ().apply { offer(value) }`.
4546 */
4647 constructor (value: E ) : this () {
4748 state = State <E >(value, null )
@@ -56,12 +57,12 @@ public class ValueBroadcastChannel<E>() : BroadcastChannel<E> {
5657
5758 private companion object {
5859 @JvmField
59- val STATE : AtomicReferenceFieldUpdater <ValueBroadcastChannel <* >, Any > = AtomicReferenceFieldUpdater .
60- newUpdater(ValueBroadcastChannel ::class .java, Any ::class .java, " state" )
60+ val STATE : AtomicReferenceFieldUpdater <ConflatedBroadcastChannel <* >, Any > = AtomicReferenceFieldUpdater .
61+ newUpdater(ConflatedBroadcastChannel ::class .java, Any ::class .java, " state" )
6162
6263 @JvmField
63- val UPDATING : AtomicIntegerFieldUpdater <ValueBroadcastChannel <* >> = AtomicIntegerFieldUpdater .
64- newUpdater(ValueBroadcastChannel ::class .java, " updating" )
64+ val UPDATING : AtomicIntegerFieldUpdater <ConflatedBroadcastChannel <* >> = AtomicIntegerFieldUpdater .
65+ newUpdater(ConflatedBroadcastChannel ::class .java, " updating" )
6566
6667 @JvmField
6768 val CLOSED = Closed (null )
@@ -257,7 +258,7 @@ public class ValueBroadcastChannel<E>() : BroadcastChannel<E> {
257258 }
258259
259260 private class Subscriber <E >(
260- private val broadcastChannel : ValueBroadcastChannel <E >
261+ private val broadcastChannel : ConflatedBroadcastChannel <E >
261262 ) : ConflatedChannel<E>(), SubscriptionReceiveChannel<E> {
262263 override fun close () {
263264 if (close(cause = null ))
0 commit comments