Skip to content

Commit fcce038

Browse files
Jonathan Cornazelizarov
Jonathan Cornaz
authored andcommitted
Add a context argument to Channel.filterNot
1 parent f0fc770 commit fcce038

File tree

1 file changed

+13
-2
lines changed
  • core/kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/channels

1 file changed

+13
-2
lines changed

core/kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/channels/Channels.kt

+13-2
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,19 @@ public inline suspend fun <E, C : SendChannel<E>> ReceiveChannel<E>.filterIndexe
577577
* This function [consumes][consume] all elements of the original [ReceiveChannel].
578578
*/
579579
// todo: mark predicate with crossinline modifier when it is supported: https://youtrack.jetbrains.com/issue/KT-19159
580-
public fun <E> ReceiveChannel<E>.filterNot(predicate: suspend (E) -> Boolean): ReceiveChannel<E> =
581-
filter { !predicate(it) }
580+
public fun <E> ReceiveChannel<E>.filterNot(context: CoroutineContext = Unconfined, predicate: suspend (E) -> Boolean): ReceiveChannel<E> =
581+
filter(context) { !predicate(it) }
582+
583+
/**
584+
* Returns a channel containing all elements not matching the given [predicate].
585+
*
586+
* The operation is _intermediate_ and _stateless_.
587+
* This function [consumes][consume] all elements of the original [ReceiveChannel].
588+
*
589+
* @suppress **Deprecated**: For binary compatibility only
590+
*/
591+
@Deprecated("For binary compatibility only", level = DeprecationLevel.HIDDEN)
592+
public fun <E> ReceiveChannel<E>.filterNot(predicate: suspend (E) -> Boolean): ReceiveChannel<E> = filterNot(predicate = predicate)
582593

583594
/**
584595
* Returns a channel containing all elements that are not `null`.

0 commit comments

Comments
 (0)