Robert Jaros
03/29/2019, 5:52 PMoctylFractal
03/29/2019, 5:55 PMoctylFractal
03/29/2019, 5:55 PMRobert Jaros
03/29/2019, 6:00 PMRobert Jaros
03/29/2019, 6:40 PMval channel = Channel<T>()
launch {
for (p in receiveChannel) channel.send(p)
}
uli
03/29/2019, 6:58 PMImplementation by Delegation
https://kotlinlang.org/docs/reference/delegation.html
And implement the remaining method to throwRobert Jaros
03/29/2019, 8:07 PMval channel = object : Channel<T>, ReceiveChannel<T> by receiveChannel {
@ExperimentalCoroutinesApi
override val isClosedForSend: Boolean
get() = throw(UnsupportedOperationException())
@ExperimentalCoroutinesApi
override val isFull: Boolean
get() = throw(UnsupportedOperationException())
override val onSend: SelectClause2<T, SendChannel<T>>
get() = throw(UnsupportedOperationException())
override fun close(cause: Throwable?): Boolean {
throw(UnsupportedOperationException())
}
@ExperimentalCoroutinesApi
override fun invokeOnClose(handler: (cause: Throwable?) -> Unit) {
throw(UnsupportedOperationException())
}
override fun offer(element: T): Boolean {
throw(UnsupportedOperationException())
}
override suspend fun send(element: T) {
throw(UnsupportedOperationException())
}
}
Robert Jaros
03/29/2019, 8:08 PMuli
03/29/2019, 9:28 PMDico
03/30/2019, 9:11 AMDico
03/30/2019, 9:11 AMDico
03/30/2019, 9:13 AMsendChannel
and a receiveChannel
and pass both to the part of your code that currently expects a Channel
. Channel
is only used when both endpoints are connected, in other words, when the send
function sends elements to the receive
function of the same Channel
reference.Robert Jaros
03/30/2019, 11:36 AM