elizarov
12/20/2017, 7:32 AMgetCancellationException
explains the purpose and behavior for this method quite well. Maybe we should rename it to reduce ambiguity and prevent its abuse? https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-job/get-cancellation-exception.htmllovis
12/21/2017, 8:59 AM>> IMPORTANT NOTE: We advise library authors to follow the same convention: add the “experimental” (e.g. com.example.experimental) suffix to your packages exposing coroutine-based APIs so that your library remains binary compatible. When the final API is released, follow these steps:copy all the APIs to com.example (without the experimental suffix), keep the experimental package around for backward compatibility. This will minimize migration issues for your users.
shayla
12/21/2017, 4:56 PMlouiscad
12/21/2017, 10:55 PMlouiscad
12/22/2017, 11:27 PMInt
value (progress of an upload I get from a callback) without incurring memory allocation nor autoboxing on each update? Note that I'm fine bridging the communication using a global property or a property on a singleton (an object
)bj0
12/23/2017, 12:24 AMBroadcastChannel
doesn't have any subscribers, will `send`s to it suspend or be dropped?napperley
12/24/2017, 10:31 PMdh44t
12/25/2017, 1:16 AMReceivingChannel
in a for
loop? Is it an iterable? I don't see anything on its hierarchybj0
12/26/2017, 5:41 PMlaunch {}
in a button click handler: java.lang.NullPointerException: Attempt to invoke interface method 'kotlin.coroutines.experimental.CoroutineContext$Element kotlin.coroutines.experimental.CoroutineContext.get(kotlin.coroutines.experimental.CoroutineContext$Key)' on a null object reference
qwert_ukg
12/27/2017, 8:10 AMgildor
12/27/2017, 8:29 AMqwert_ukg
12/28/2017, 5:31 AMkingsley
12/28/2017, 2:21 PMonX
functions look weird. Personal opinion thoughkingsley
12/28/2017, 2:23 PMjw
01/01/2018, 4:11 AMasad.awadia
01/02/2018, 1:11 PMvitrox1
01/02/2018, 3:37 PMbj0
01/02/2018, 8:07 PMpakoito
01/02/2018, 9:41 PMjw
01/03/2018, 5:18 AMbj0
01/03/2018, 8:46 PMChannel
in a coroutine, and I want that channel closed when the coroutine is canceled, is the only way to catch the CancellationException
?bartosz.malkowski
01/04/2018, 10:50 AMenleur
01/04/2018, 12:22 PMsuspend fun call(): Element {
return suspendCancellableCoroutine { continuation ->
client.request(Element("request"), object : Handler {
override fun success(response: Element) {
continuation.resume(response)
}
override fun error(response: Element) {
continuation.resume(response)
}
})
}
}
bartosz.malkowski
01/04/2018, 1:42 PMbdawg.io
01/04/2018, 11:58 PMtry {
val element = xmpp.request(Element("request"))
println("Received element: $element")
} catch (error: FailureException) {
println("oops... error! ${error.condition}")
} catch (timeout: TimeoutException) {
println("timeout")
}
paulblessing
01/05/2018, 6:46 PMclass ResourceManager<out T>(private val resource: T, readConcurrency: Int) {
private val readWriteLock = ReentrantReadWriteLock()
private val readContext = newFixedThreadPoolContext(readConcurrency, "reader")
private val writeContext = newSingleThreadContext("writer")
suspend fun <R> read(block: (T) -> R): R = withContext(readContext) {
readWriteLock.readLock().withLock { block(resource) }
}
suspend fun <R> write(block: (T) -> R): R = withContext(writeContext) {
readWriteLock.writeLock().withLock { block(resource) }
}
}
Going this way seems to do the trick pretty well, though I still have a dirty feeling about using the locks since they'll block. Maybe that's OK since these are all background threads but I haven't fully convinced myself that there aren't gotchas.Jan Koprowski
01/06/2018, 9:40 PMjw
01/08/2018, 3:28 AMstreetsofboston
01/09/2018, 8:58 PMCoroutineContext
that allows you to do so.
It is very much like the RxJava’s TestScheduler
and its methods triggerActions
, advanceTimeBy
, etc.
It does so by implementing a Coroutine Dispatcher (for speeding up (virtual) time) and a Coroutine Exception Handler (for testing thrown exceptions).
The main TestCoroutineContext
class and some unit-tests can be found here:
https://gist.github.com/streetsofboston/6ea225c61566e6d349883082fbb9f020louiscad
01/10/2018, 4:28 PMnosuspend
or similar becomes a thing, to prevent accidental bad usage of the APIs I designed (to use Bundle
on Android with properties on a shared object
)louiscad
01/10/2018, 4:28 PMnosuspend
or similar becomes a thing, to prevent accidental bad usage of the APIs I designed (to use Bundle
on Android with properties on a shared object
)dave08
01/10/2018, 9:12 PMlouiscad
01/10/2018, 10:19 PMcrossinline
lambda could allow suspension implicitly when you think about it.dave08
01/11/2018, 3:48 AMlouiscad
01/11/2018, 7:33 AMdave08
01/11/2018, 8:26 AM