asynchronous - Are coroutines just syntactic sugar around completion handlers? -


are coroutines syntactic sugar around completion blocks , completion blocks created under hood? or concept of coroutines more complex , broad compiler trick aka syntactic sugar

it's not syntactic sugar, not @ all. coroutines do not block threads, suspend execution, encourage non-blocking concurrent programming.

coroutines not rely on features of operating system or jvm (e.g. not mapped native threads). instead, coroutines , suspend functions particularly transformed compiler producing state machine capable of handling suspensions in general , passing around suspending coroutines keeping state. enabled continuations, added parameter each , every suspending function compiler; technique called “continuation-passing style”.

for details please have @ https://github.com/kotlin/kotlin-coroutines/blob/master/kotlin-coroutines-informal.md


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -