15 Mayıs 2020 Cuma

Coroutine

Giriş
Açıklaması şöyle. Artık bir çok programlama dili için coroutine kütüphaneleri var. Thread kullanmadan paralel işlemler elde etmek için kullanılıyor.
Coroutines are essentially lightweight threads that allow your applications to squeeze more juice out of the machines they are running on, without needing to manually manage the threads executing them. Coroutines add a new abstraction, further removing you (the developer) away from the lifecycle of threads. This abstraction allows a single thread to context switch between various tasks and therefore making better use of the thread’s time. It spends less time sitting around awaiting a result (from a potentially slow I/O task) and can instead continue to be useful by working on a task issued by another coroutine.
Guaranteed Order
Bir işi yani task'ı yerine getirmek için kullanılan Corutine'lere bir sıra yani order vermek gerekiyor. Açıklaması şöyle.
So, to be more accurate, one coroutine is not exactly one “task” but rather a sequence of “sub-tasks” to execute in a specific, guaranteed order.
Suspension Function
Açıklaması şöyle.
Suspending functions may suspend the execution of the current coroutine without blocking the current thread.
Kotlin ve suspend Anahtar Kelimesi
Kotlin suspend yazısına taşıdım

Hiç yorum yok:

Yorum Gönder