fstn
12/01/2017, 8:50 AMAVERTISSEMENT io.netty.bootstrap.ServerBootstrap$ServerBootstrapAcceptor forceClose Failed to register an accepted channel: [id: 0x01a0436e, L:0.0.0.0/0.0.0.0:8080]
java.lang.IllegalStateException
at io.vertx.core.net.impl.VertxEventLoopGroup.next(VertxEventLoopGroup.java:47)
fstn
12/01/2017, 10:29 AMjava.lang.IllegalStateException: Job StandaloneCoroutine{Completed}@6daf38a4 is already complete, but is being completed with kotlin.Unit]]`
When calling:
suspend fun getValidNextEvent(node: Node, messageBody: MessageBody): MutableList<Event<MessageBody>> {
return suspendCoroutineOrReturn { cont ->
val eventsToEmit = mutableListOf<Event<MessageBody>>()
....
cont.resume(eventsToEmit);
}
}
Paul Woitaschek
12/01/2017, 1:50 PMkoufa
12/01/2017, 2:04 PMfred.deschenes
12/01/2017, 2:08 PMnhellwig
12/01/2017, 3:00 PMkoufa
12/01/2017, 7:29 PMcoroutineContext
of a parent to child coroutines?fstn
12/02/2017, 7:30 AMval mockContextManager = Mockito.mock(ContextManager::class.java)
Mockito.`when`(mockContextManager.get(1)).thenReturn(2)
where get is a suspend functionfstn
12/02/2017, 6:08 PMmiha-x64
12/03/2017, 2:10 PMsuspend fun
is open
. What's going on, why?elizarov
12/04/2017, 12:02 PMkotlinx.coroutines
version 0.20
for Kotlin 1.2.0 with sequence-like extensions for channels, improvements to parent-child relations, more Android support and fixes. See full changes here: https://github.com/Kotlin/kotlinx.coroutines/releases/tag/0.20kevinherron
12/04/2017, 11:21 PMelizarov
12/05/2017, 6:58 AMclose
that performs a graceful closing (letting actor finish all the processing). However, the close
does not assume that you will be joining them.bj0
12/05/2017, 3:59 PMclose
instead of cancel, so you let it finish all processingpakoito
12/05/2017, 10:05 PMcoroutineContext
what do you mean in this context? literally accessing the field on your parent coroutine, if you’re in one of its blocksdave08
12/06/2017, 3:20 AMUnconfined
is the equivalent of not using a scheduler in Rx, and it's very common, say in android, to want to run mainly on the current thread (with fan out/in, that SHOULD block the current thread only for the result), like in an IntentService that already has a working thread (that shouldn't stop until all tasks are finished, otherwise there could be leaks...)... in that case, is it better to use runBlocking
or launch(Unconfined)
, or is there no difference...? There's no clear rules about this in the docs, only 'hints' that seem a bit contradictory at times...
Also, when is there a need for the top level yield
function I mentioned before? Does it have to do with certain contexts being CorotineStart.dispatched by default or not?dave08
12/06/2017, 3:37 AMsuspend fun getX()
needs to be able to be run either in main thread context using CommonPool
, or in an existing coroutineContext
or in an already existing worker thread in a blocking fashion, depending on from where it's called, what's the recommended way to do each, and when would I have to yield
?dave08
12/06/2017, 3:43 AMsubscibeOn
and observeOn
to do all this (but coroutines are much better in other aspects... 😉 ). In coroutines things seem much more complex in this aspect, and the 'danger' you mentioned... does that also exist in rx?elizarov
12/06/2017, 8:17 AMlouiscad
12/06/2017, 11:22 AMBluetoothGattCallback
instance with the overriden methods you'll need once, when connecting, and the connection result, the attributes discovery and read/write operations are passed to this callback. What I aim at is to use coroutines to handle failures without callback hell, in a procedural style, and to handle success this way too. The issue that I have is that this BluetoothGattCallback
listens to too many different things. When connecting, I'm just interested in the connectionState callback. When writing data, I'm just interested in waiting for completion or error and knowing if it succeeded or failed, when reading data, just need the data, or exception... Is it possible to separate these things from this god callback?
For reference, here is the key method with the two BluetoothGatt
and BluetoothGattCallback
key classes in its signature:
<https://developer.android.com/reference/android/bluetooth/BluetoothDevice.html#connectGatt(android.content.Context>, boolean, android.bluetooth.BluetoothGattCallback)
(select the whole link to get directed to the right method, slack doesn't like this url formatting)
Please, reply in thread since this is quite specific to Android, so this channel doesn't get too clutteredr4zzz4k
12/06/2017, 11:51 AMcamdenorrb
12/06/2017, 3:44 PMdekans
12/06/2017, 4:57 PMawait
a block execution to not block the current thread, but I don't care about the result value. Is there a better practice for it than calling await()
without using the result?dave08
12/06/2017, 5:29 PMNote, that we can replicate the same behaviour that we saw with channels by using Rx publish operator and connect method with it.really true? In Rx,
publish
makes a ConnectableObservable
which I would think is the equivalent of a BroadcastChannel
?
Also is there a simple way of making a produce { }
for a BroadcastChannel
?jimn
12/06/2017, 6:25 PMArshak Ulubabyan
12/06/2017, 8:09 PMbj0
12/08/2017, 4:20 PMwhile / try / receive
you can just use a for
loop over channel
. As for testing, runBlocking
is generally used to make the function wait until the coroutines are done.elizarov
12/09/2017, 12:52 PMreceive
and for (x in channel)
loop are both non-terminalkoufa
12/09/2017, 10:16 PMactor
construct. Now I am calling the suspend
fun loadProducts()
from a runBlocking
block directly. The question remains how I could make the runBlocking
block to wait for the consumeEach
in loadProducts()
to finish, controlling somehow the mock channel
I return from the mocked loadProducts()
in my test. I hope I did explained it well. Thank you in advance for your interest.nil2l
12/11/2017, 10:53 AMnil2l
12/11/2017, 10:53 AMgildor
12/11/2017, 10:55 AMNetworkCallStateProducer
and can just create channel and cache it to propertynil2l
12/11/2017, 10:56 AMprivate val channel = Channel< NetworkCallState<T> >()
fun getChannel(): ReceiveChannel< NetworkCallState<T> > = channel
suspend fun produce() {
do {
val state: NetworkCallState<T> = suspendCoroutine { cont = it }
channel.send(state)
} while (!state.status.isCompleted())
channel.close()
}
gildor
12/11/2017, 11:20 AMnil2l
12/11/2017, 11:23 AMChannel<State>
for a call.
I know sync calls should be used here. But currently I can use only async calls.gildor
12/11/2017, 11:27 AMwhile
there, you just return channel. Also, you probably want something like BroadcastChannel to support multiple consumers, now you should create a channel for each consumernil2l
12/11/2017, 11:31 AM(state) -> Unit
gildor
12/11/2017, 11:41 AMoffer
instead of send
nil2l
12/11/2017, 11:42 AMgetChannel().find { it.status.isCompleted() }
.uli
12/11/2017, 8:32 PMoffer
.it might loose your `state`object if the consume is to slowchannel.send()
inside run.blocking {}
inside your callback? There you have your coroutine context and depending on the network stack, you might even get back pressure, if the consumer is too slow.