elizarov
08/31/2017, 12:45 PMdragas
08/31/2017, 1:00 PMfun main(args: Array<String>) = runBlocking()
{
val actor = getIntActor()
delay(1000)
}
fun getIntActor() = actor<Int>(CommonPool)
{
consumeEach(::consumeInt)
}
fun consumeInt(it : Int)
{
println(it)
}
elizarov
08/31/2017, 2:20 PMkotlinx.coroutines
version 0.18)dragas
09/01/2017, 7:36 AMkotlinx.coroutines 0.18
and kotlin 1.1.4-2
in a multi module gradle project, And it doesn't work anywhere, really. Be it the example I provided, or deep in the project. This is the only place I tried using actors at.
https://pastebin.com/pgMgydRK
for(response in channel)
doesn't throw that and seems to work as intended.consumeEach
on regular channels throws that too, but with Exception in thread "kotlinx.coroutines.DefaultExecutor" Exception in thread "main" java.lang.ClassCastException: java.lang.Object cannot be cast to java.lang.Boolean
fun main(args: Array<String>) = runBlocking()
{
val channel = Channel<Int>(Channel.UNLIMITED)
channel.consumeEach { println(it) }
delay(1000)
}
fun consumeInt(it: Int)
{
println(it)
}
elizarov
09/01/2017, 7:45 AMdragas
09/01/2017, 10:45 AMelizarov
09/01/2017, 4:53 PMT.kt
with the code above of your, pressed Alt+ENTER many times to add all the imports
* Now when I run it it just works, does not crashT.kt
):
import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.channels.actor
import kotlinx.coroutines.experimental.channels.consumeEach
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.runBlocking
fun main(args: Array<String>) = runBlocking()
{
val actor = getIntActor()
delay(1000)
}
fun getIntActor() = actor<Int>(CommonPool)
{
consumeEach(::consumeInt)
}
fun consumeInt(it : Int)
{
println(it)
}
dragas
09/01/2017, 5:51 PM