Marko Mitic
12/12/2019, 8:34 PMdelay
wait for given real time, not CPU time. I'm assuming that default implementation doesn't take CPU sleep into account, I'm I right? If during 5min delay CPU sleeps for 15 min, will delay effectively take 20min?Marko Mitic
12/12/2019, 9:07 PMoctylFractal
12/12/2019, 9:11 PMdelay
depends on the Dispatcher, so it probably differs if you're talking about Dispatcher.Main
vs Dispatcher.Default
. iirc Main
tends to use the platform's waiting utilities, so on android that's `Handler`: https://github.com/Kotlin/kotlinx.coroutines/blob/master/ui/kotlinx-coroutines-android/src/HandlerDispatcher.kt#L139octylFractal
12/12/2019, 9:11 PMpostDelayed
says it uses https://developer.android.com/reference/android/os/SystemClock.html#uptimeMillis()octylFractal
12/12/2019, 9:34 PMDefault
uses System.nanoTime()
on android, which probably is CPU time as welloctylFractal
12/12/2019, 9:36 PMsuspendCancellableCoroutine
in addition to AlarmManager
+ https://developer.android.com/reference/android/app/AlarmManager.html#ELAPSED_REALTIME , or if you need it more ingrained, write a new dispatcher on top of that.Marko Mitic
12/12/2019, 10:38 PMoctylFractal
12/12/2019, 10:42 PMShmuel Rosansky [G]
12/13/2019, 4:20 AMShmuel Rosansky [G]
12/13/2019, 4:22 AMMarko Mitic
12/13/2019, 10:42 AM