Skip to content

Commit 8968e2f

Browse files
committed
Remove already deprecated experimental SendChannel.isFull and ReceiveChannel.isEmpty properties
See "Deprecate SendChannel.isFull and ReceiveChannel.isEmpty properties #1053"
1 parent 3e42850 commit 8968e2f

File tree

7 files changed

+5
-34
lines changed

7 files changed

+5
-34
lines changed

binary-compatibility-validator/reference-public-api/kotlinx-coroutines-core.txt

-3
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,6 @@ public final class kotlinx/coroutines/channels/ConflatedBroadcastChannel : kotli
700700
public final fun getValueOrNull ()Ljava/lang/Object;
701701
public fun invokeOnClose (Lkotlin/jvm/functions/Function1;)V
702702
public fun isClosedForSend ()Z
703-
public fun isFull ()Z
704703
public fun offer (Ljava/lang/Object;)Z
705704
public fun openSubscription ()Lkotlinx/coroutines/channels/ReceiveChannel;
706705
public fun send (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
@@ -724,7 +723,6 @@ public abstract interface class kotlinx/coroutines/channels/ReceiveChannel {
724723
public abstract fun getOnReceive ()Lkotlinx/coroutines/selects/SelectClause1;
725724
public abstract fun getOnReceiveOrNull ()Lkotlinx/coroutines/selects/SelectClause1;
726725
public abstract fun isClosedForReceive ()Z
727-
public abstract fun isEmpty ()Z
728726
public abstract fun iterator ()Lkotlinx/coroutines/channels/ChannelIterator;
729727
public abstract fun poll ()Ljava/lang/Object;
730728
public abstract fun receive (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
@@ -742,7 +740,6 @@ public abstract interface class kotlinx/coroutines/channels/SendChannel {
742740
public abstract fun getOnSend ()Lkotlinx/coroutines/selects/SelectClause2;
743741
public abstract fun invokeOnClose (Lkotlin/jvm/functions/Function1;)V
744742
public abstract fun isClosedForSend ()Z
745-
public abstract fun isFull ()Z
746743
public abstract fun offer (Ljava/lang/Object;)Z
747744
public abstract fun send (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
748745
}

kotlinx-coroutines-core/common/src/channels/AbstractChannel.kt

+5-7
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ internal abstract class AbstractSendChannel<E> : SendChannel<E> {
167167
// ------ SendChannel ------
168168

169169
public final override val isClosedForSend: Boolean get() = closedForSend != null
170-
public final override val isFull: Boolean get() = full
171-
private val full: Boolean get() = queue.nextNode !is ReceiveOrClosed<*> && isBufferFull // TODO rename to `isFull`
170+
private val isFull: Boolean get() = queue.nextNode !is ReceiveOrClosed<*> && isBufferFull
172171

173172
public final override suspend fun send(element: E) {
174173
// fast path -- try offer non-blocking
@@ -403,7 +402,7 @@ internal abstract class AbstractSendChannel<E> : SendChannel<E> {
403402
private fun <R> registerSelectSend(select: SelectInstance<R>, element: E, block: suspend (SendChannel<E>) -> R) {
404403
while (true) {
405404
if (select.isSelected) return
406-
if (full) {
405+
if (isFull) {
407406
val enqueueOp = TryEnqueueSendDesc(element, select, block)
408407
val enqueueResult = select.performAtomicIfNotSelected(enqueueOp) ?: return
409408
when {
@@ -562,8 +561,7 @@ internal abstract class AbstractChannel<E> : AbstractSendChannel<E>(), Channel<E
562561
// ------ ReceiveChannel ------
563562

564563
public final override val isClosedForReceive: Boolean get() = closedForReceive != null && isBufferEmpty
565-
public final override val isEmpty: Boolean get() = empty
566-
private val empty: Boolean get() = queue.nextNode !is Send && isBufferEmpty // TODO rename to `isEmpty`
564+
private val isEmpty: Boolean get() = queue.nextNode !is Send && isBufferEmpty
567565

568566
@Suppress("UNCHECKED_CAST")
569567
public final override suspend fun receive(): E {
@@ -750,7 +748,7 @@ internal abstract class AbstractChannel<E> : AbstractSendChannel<E>(), Channel<E
750748
private fun <R> registerSelectReceive(select: SelectInstance<R>, block: suspend (E) -> R) {
751749
while (true) {
752750
if (select.isSelected) return
753-
if (empty) {
751+
if (isEmpty) {
754752
val enqueueOp = TryEnqueueReceiveDesc(select, block as (suspend (E?) -> R), nullOnClose = false)
755753
val enqueueResult = select.performAtomicIfNotSelected(enqueueOp) ?: return
756754
when {
@@ -784,7 +782,7 @@ internal abstract class AbstractChannel<E> : AbstractSendChannel<E>(), Channel<E
784782
private fun <R> registerSelectReceiveOrNull(select: SelectInstance<R>, block: suspend (E?) -> R) {
785783
while (true) {
786784
if (select.isSelected) return
787-
if (empty) {
785+
if (isEmpty) {
788786
val enqueueOp = TryEnqueueReceiveDesc(select, block, nullOnClose = true)
789787
val enqueueResult = select.performAtomicIfNotSelected(enqueueOp) ?: return
790788
when {

kotlinx-coroutines-core/common/src/channels/Channel.kt

-20
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,6 @@ public interface SendChannel<in E> {
2626
@ExperimentalCoroutinesApi
2727
public val isClosedForSend: Boolean
2828

29-
/**
30-
* Returns `true` if the channel is full (out of capacity) and the [send] attempt will suspend.
31-
* This function returns `false` for [isClosedForSend] channel.
32-
*
33-
* @suppress **Will be removed in next releases, no replacement.**
34-
*/
35-
@ExperimentalCoroutinesApi
36-
@Deprecated(level = DeprecationLevel.ERROR, message = "Will be removed in next releases without replacement")
37-
public val isFull: Boolean
38-
3929
/**
4030
* Adds [element] into to this channel, suspending the caller while the buffer of this channel is full
4131
* or if it does not exist, or throws exception if the channel [isClosedForSend] (see [close] for details).
@@ -148,16 +138,6 @@ public interface ReceiveChannel<out E> {
148138
@ExperimentalCoroutinesApi
149139
public val isClosedForReceive: Boolean
150140

151-
/**
152-
* Returns `true` if the channel is empty (contains no elements) and the [receive] attempt will suspend.
153-
* This function returns `false` for [isClosedForReceive] channel.
154-
*
155-
* @suppress **Will be removed in next releases, no replacement.**
156-
*/
157-
@ExperimentalCoroutinesApi
158-
@Deprecated(level = DeprecationLevel.ERROR, message = "Will be removed in next releases without replacement")
159-
public val isEmpty: Boolean
160-
161141
/**
162142
* Retrieves and removes the element from this channel suspending the caller while this channel is empty,
163143
* or throws [ClosedReceiveChannelException] if the channel [isClosedForReceive].

kotlinx-coroutines-core/common/src/channels/ConflatedBroadcastChannel.kt

-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ public class ConflatedBroadcastChannel<E>() : BroadcastChannel<E> {
102102
}
103103

104104
public override val isClosedForSend: Boolean get() = _state.value is Closed
105-
public override val isFull: Boolean get() = false
106105

107106
@Suppress("UNCHECKED_CAST")
108107
public override fun openSubscription(): ReceiveChannel<E> {

kotlinx-coroutines-core/common/test/channels/TestChannelKind.kt

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ private class ChannelViaBroadcast<E>(
5555

5656
override val isClosedForReceive: Boolean get() = sub.isClosedForReceive
5757
@Suppress("DEPRECATION_ERROR")
58-
override val isEmpty: Boolean get() = sub.isEmpty
5958

6059
override suspend fun receive(): E = sub.receive()
6160
override suspend fun receiveOrNull(): E? = sub.receiveOrNull()

reactive/kotlinx-coroutines-reactive/src/Publish.kt

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ private class PublisherCoroutine<in T>(
7171
private var shouldHandleException = false // when handleJobException is invoked
7272

7373
override val isClosedForSend: Boolean get() = isCompleted
74-
override val isFull: Boolean = mutex.isLocked
7574
override fun close(cause: Throwable?): Boolean = cancelCoroutine(cause)
7675
override fun invokeOnClose(handler: (Throwable?) -> Unit) =
7776
throw UnsupportedOperationException("PublisherCoroutine doesn't support invokeOnClose")

reactive/kotlinx-coroutines-rx2/src/RxObservable.kt

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ private class RxObservableCoroutine<T: Any>(
6464
private val _signal = atomic(OPEN)
6565

6666
override val isClosedForSend: Boolean get() = isCompleted
67-
override val isFull: Boolean = mutex.isLocked
6867
override fun close(cause: Throwable?): Boolean = cancelCoroutine(cause)
6968
override fun invokeOnClose(handler: (Throwable?) -> Unit) =
7069
throw UnsupportedOperationException("RxObservableCoroutine doesn't support invokeOnClose")

0 commit comments

Comments
 (0)