Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A gentle introduction to Kotlin Coroutines

A gentle introduction to Kotlin Coroutines

Arturo Mejia

March 25, 2019
Tweet

More Decks by Arturo Mejia

Other Decks in Programming

Transcript

  1. Reactive Extensions @ArturoMejia481 You have to change the way that

    you approach a problem. Operators RX Schedulers Streams
  2. Suspend @ArturoMejia481 The Kotlin compiler transforms the function to a

    callback model and uses state machines to know when a function should be suspended or resume.
  3. Dispatchers @ArturoMejia481 DEFAULT (Computational) Uses the # cores of the

    CPU, not good for computations like I/O, network, disk, etc. IO designed for doing blocking I/O operations, max #64 thread, share the pool with DEFAULT. MAIN designed to operate UI objects. Indicate in which thread pool a coroutine should run
  4. Interoperate @ArturoMejia481 kotlinx-coroutines-rx2: Utilities for Rx. kotlinx-coroutines-jdk8: Integration with JDK8

    CompletableFuture (Android API level 24). kotlinx-coroutines-android: Designed to operate UI objects.