<@U6P03BM0W> I’m somewhat lost at what problem you...
# coroutines
e
@dave08 I’m somewhat lost at what problem you are trying to solve and what is the solution your are trying to apply. I don’t see how sending over channel inside a mutex should do anything. Can you post somewhere (like a gist) a larger example (a unit test, maybe?) that demonstrates what you are trying to do and what does not work?
u
I think @dave08 means to use the mutex approach as an alternative serialisation approach, instead of having a channel
d
Right!
but both have their problems...
u
What's the issue with the channel approach? Sounds just right to me
d
It was running well on the IntentService, but the SyncAdapter just terminated right away.. I tried join() but that stalled the whole app
Copy code
val syncRequestChannel = Channel<SyncRequest>(Channel.CONFLATED)
val syncStarterJob by lazy {
		launchSyncStarter(syncRequestChannel)
	}
    fun launchSyncStarter(syncRequestChannel: ReceiveChannel<SyncRequest>) = launch(CommonPool) {
        syncRequestChannel.consumeEach { with(it) {
                // Sync instructions
        } }
    }

    override fun onSyncStart(context: Context, currSyncResult: SyncResult) {
        runBlocking { syncRequestChannel.send(Unit) }
}
@uli
u
which class is that? which onSyncStart are you overriding?
d
But that's the first way I tried..
u
right, what is the base class of SyncAction?
Or is it just a
SyncHandler
?
d
It's just a regular class not an android component..
u
I was wondering because of the override, But now I got it. found the
SyncHandler
interface