# Structured Concurrency Anniversary

DevFeed: [Structured Concurrency Anniversary](<https://devfeed.tech/articles/structured-concurrency-anniversary-26028.md>)

Original publisher: [Read original article](<https://elizarov.medium.com/structured-concurrency-anniversary-f2cc748b2401?source=rss-4762e889f8fc------2>)

Author: Roman Elizarov

Published: 2019-09-28T15:02:02Z

Content type: article

Language: en

Sources: [Stories by Roman Elizarov on Medium](<https://devfeed.tech/sources/stories-by-roman-elizarov-on-medium.md>)

Topics: [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [kotlin-coroutines](<https://devfeed.tech/topics/kotlin-coroutines.md>), [Android](<https://devfeed.tech/topics/android.md>), [reactive](<https://devfeed.tech/topics/reactive.md>), [Documentation](<https://devfeed.tech/topics/documentation.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [asynchronous](<https://devfeed.tech/tags/asynchronous.md>), [code](<https://devfeed.tech/tags/code.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [documentation](<https://devfeed.tech/tags/documentation.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-coroutines](<https://devfeed.tech/tags/kotlin-coroutines.md>), [programming](<https://devfeed.tech/tags/programming.md>), [reactive](<https://devfeed.tech/tags/reactive.md>), [reactive-streams](<https://devfeed.tech/tags/reactive-streams.md>), [structured-concurrency](<https://devfeed.tech/tags/structured-concurrency.md>)

## AI overview

This retrospective examines the first year of Structured Concurrency in Kotlin Coroutines. It describes its origins in backend asynchronous programming, adoption in Android lifecycle-aware development, and its role in Kotlin Flows and reactive streams.

## Source excerpt

Photo by Annie Spratt on Unsplash A little over a year ago I announced big conceptual shift in the design of Kotlin Coroutines called Structured Concurrency. From that moment on, it took our team about a month to make the first stable 1.0.0 release of kotlinx.coroutines library. After a year of further work, kotlinx.coroutines had added stable support for cold flows that integrate nicely with reactive streams. The library had reached version 1.3.2 by now. It is good time to look back and see how it all worked out -- what was great, what could be improved. Structured Concurrency accomplished more than we hoped for. Originally, the design of structured concurrency was based on the woes experienced by backend developers trying to implement all sorts of asynchronous and concurrent logic. It was focused on making sure that you cannot ever lose a running coroutine or an exception. The key building block we added back then is coroutineScope { ... } function, which encapsulates concurrent operations and limits their scope to the scope of the current call. There was not much else to it, so our recommendation to UI developers was to implement CoroutineScope interface in various "closeable" entities of their applications. We envisioned a simple picture with a simple scope hierarchy. It turned out to be more elaborate in practice. Structured Concurrency was rapidly adopted by Android, which has quite complicated life-cycles. Android libraries added extensions like lifecycleScope and viewModelScope, enabling concise and safe integration of coroutines with those concepts. It became apparent that code looks clearer when an object encapsulating the scope is separate from the rest of code. Introductory Android Codelab on Coroutines recommends defining coroutine scope like this: private val scope = CoroutineScope(...) Nowadays, this style increasingly looks more appealing, so it's time to adjust our documentation to reflect it. At the same time, structured concurrency laid a solid fou