Hong Phuc
08/30/2025, 4:44 AMMarking a functiongives it the capability to suspend the coroutine, but it will only actually suspend the coroutine if it internally calls another suspend function that suspends the coroutine. The suspend functions that directly suspend a coroutine are in the standard library. Among these aresuspend
andsuspendCoroutine()
. You will not often use these. They are most commonly used to convert non-coroutine APIs into suspend functions.suspendCancellableCoroutine()
Some of the commonly used functions that indirectly suspend a coroutine areI found it in this Stackoverflow post.,withContext()
,delay()
andJob.join()
.Deferred.await()
Joffrey
08/30/2025, 5:15 AM