Hello, everyone :wave:. In case someone interested...
# coroutines
n
Hello, everyone 👋. In case someone interested, recently I've written an article about Coroutines beyond their typical role in concurrency –https://y9vad9.com/article/coroutines-are-not-just-about-concurrency Inside, I explore Coroutines' fundamental building blocks (coroutine primitives), their internal workings, and provide examples of how they can be used completely independent of concurrency tasks (Sequence, DeepRecursiveScope and other small usecases) Feedback is appreciated 😀
👍🏻 1
👏 1
p
Skimmed over it; overall good stuff, kudos for touching synchronous coroutines I’d rephrase those state descriptions in lazy iterator:
“It might be waiting for an operation or further processing to make an item available.”
This is too abstract IMO, NOT_READY simply means iterator consumer has not called “hasNext()” or “next()” yet after consuming last item (it is pending resuming the continuation that will produce the next item)
Would be nice to mention the intrinsic
createCoroutineUnintercepted
and
startCoroutineUninterceptedOrReturn
before mentioning all other non-intrinsic stdlib stuff as those are the very core building blocks of it all
👍 1
n
Thanks for your feedback, really appreciate your suggestions. Gonna revise my article tomorrow 😃
m
Thanks Vadym, you gave a great description of how contexts are managed in structured concurrency. As another example, my Klogging library defines a
LogContext
class that holds context items to include in log events.
❤️ 1
i
Hey! Have you read the official documentation on inner workings of coroutines https://github.com/JetBrains/kotlin/blob/master/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/coroutines-codegen.md? It goes much deeper in terms of intrinsics and how compiler turns sequential code into suspendable.
n
my article wasn't about how it goes internally, some things are needed to be covered, but I don't think that everything. Main point was about how coroutines can replace tasks, where we do not need any concurrency.
Yes, I've already read it about a long ago, but I think this is a part for another article 🙂