Exerosis
06/01/2022, 12:44 AMrunBlocking(MyContext) {
launch(<http://Dispatchers.IO|Dispatchers.IO>) {
//doesn't contain my context anymore
}
launch {
//still contains my context
}
}
I need to be an identifier that indicates that a call is part of the same sequence of calls. Worst case even if I could just get it to log some kind of warning that would be a good start.Zach Klippenstein (he/him) [MOD]
06/01/2022, 5:03 AMDALDEI
06/04/2022, 10:46 AMDALDEI
06/04/2022, 10:47 AMExerosis
06/05/2022, 2:06 AMval context = CustomContext()
suspend fun makeCall(callback: suspend () -> (Unit)) {
if (currentCoroutineContext()[CustomContext] != null)
//callback directly or indirectly recursively called makeCall
else withContext(context) { callback() }
}
however if execution branches this still detects the recursive call (as it should) even if it's at a later time (which is helpful in some cases but in my case I would like to handle that differently)