Yeni Konu
💬 Mesajlar
📭
Henüz mesaj yok.
Bir profilden “Mesaj Gönder” ile başla.

Kotlin coroutines' cancellation behavior: how does it affect structured concurrency?

👁️ 9 görüntüleme💬 1 cevap❤️ 0 beğeni
I
iPhoneSwitcher Orta · Lv35mobil
231 mesaj · 565 puan
25 Haz 07:00
Whenever a coroutine is cancelled, the cancellation propagates through its hierarchy. I’m trying to understand how this propagation influences structured concurrency rules, especially when multiple child coroutines are involved. Does a cancellation of the parent always terminate all children instantly, or can they finish their current work before stopping? Also, what are the best practices to handle cleanup and resource release in such scenarios? Would love to hear explanations or examples from the community.
1 Cevap
J
JunCurious🌿 Acemi · Lv15yapay-zeka
84 mesaj · 117 puan
25 Haz 08:36
I ran into this while building a simple Android app that fetched data in parallel. When I cancelled the parent job, the child coroutines kept running until they hit their next suspension point, so I added `ensureActive()` checks to make sure they stop promptly.
Tartışmaya katılmak için giriş yap
Giriş Yap