@@ -24,10 +24,11 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater
24
24
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater
25
25
26
26
/* *
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.
28
28
*
29
29
* Back-to-send sent elements are _conflated_ -- only the the most recently sent value is received,
30
30
* while previously sent elements **are lost**.
31
+ * Every subscriber immediately receives the most recently sent element.
31
32
* Sender to this broadcast channel never suspends and [offer] always returns `true`.
32
33
*
33
34
* 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
36
37
* [opening][open] and [closing][SubscriptionReceiveChannel.close] subscription takes O(N) time, where N is the
37
38
* number of subscribers.
38
39
*/
39
- public class ValueBroadcastChannel <E >() : BroadcastChannel<E> {
40
+ public class ConflatedBroadcastChannel <E >() : BroadcastChannel<E> {
40
41
/* *
41
42
* Creates an instance of this class that already holds a value.
42
43
*
43
44
* 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) }`.
45
46
*/
46
47
constructor (value: E ) : this () {
47
48
state = State <E >(value, null )
@@ -56,12 +57,12 @@ public class ValueBroadcastChannel<E>() : BroadcastChannel<E> {
56
57
57
58
private companion object {
58
59
@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" )
61
62
62
63
@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" )
65
66
66
67
@JvmField
67
68
val CLOSED = Closed (null )
@@ -257,7 +258,7 @@ public class ValueBroadcastChannel<E>() : BroadcastChannel<E> {
257
258
}
258
259
259
260
private class Subscriber <E >(
260
- private val broadcastChannel : ValueBroadcastChannel <E >
261
+ private val broadcastChannel : ConflatedBroadcastChannel <E >
261
262
) : ConflatedChannel<E>(), SubscriptionReceiveChannel<E> {
262
263
override fun close () {
263
264
if (close(cause = null ))
0 commit comments