conner
07/08/2020, 9:36 PMSIGSEGV (0xb), C [libsystem_pthread.dylib+0x15ad] pthread_mutex_lock+0x0) when the value is created outside of a callbackFlow but not when it's inside, what would that mean? in other words,
val thing = createNativeThing()
callbackFlow {
thing.onCallback = {
offer(it)
}
thing.start()
}
crashes but
callbackFlow {
val thing = createNativeThing()
thing.onCallback = {
offer(it)
}
thing.start()
}
does notconner
07/08/2020, 9:37 PMgroostav
07/08/2020, 9:40 PMcallbackFlow factory move threads, and I think the answer to that is yes. So probably what your seeing is createNativeThing() being on thread A and setOnCallback being on thread B, which might be giving it some troubleconner
07/08/2020, 9:42 PMthing to exist outside of the flow?groostav
07/08/2020, 9:43 PMDispatchers.Unconfined, im still new to flows som not sure how you'd tell callback flow thats what you wantgroostav
07/08/2020, 9:44 PMcallbackFlow{ ... }.flowOn(Dispatchers.Unconfined)groostav
07/08/2020, 9:45 PMgroostav
07/08/2020, 9:45 PMgroostav
07/08/2020, 9:47 PMval myThread = ExecutorService().asDispatcher()
val thing = withContext(myThread) { createNativeThing() }
callbackFlow {
withContext(myThread){
thing.onCallback = { offer(it) }
thing.start()
}
}.flowOn(myThread)groostav
07/08/2020, 9:47 PMflowOn might not be necessarygroostav
07/08/2020, 9:47 PMmyThreadconner
07/08/2020, 9:57 PMconner
07/08/2020, 10:12 PMflowOn, for future reference)tseisel
07/09/2020, 7:38 AMawaitClose at the end of the callbackFlow block. Is it on purpose ?conner
07/09/2020, 1:11 PMawaitClose {} -- would that be related?