I have watched the "Kotlin Coroutines in Practice" talk by Roman Elizarov and learned about the Actor pattern to confine shared mutable state to a coroutine. In this talk, actors are defined using a function whose parameters are ReceiveChannel (for inputs) or SendChannel (for outputs).
Since those actors are defined as functions, how does they relate to classes ? Does anyone has concrete examples of how to structure a program with coroutines-based actors ?
a
Allan Wang
01/29/2019, 9:05 PM
If you look at the source for actors, they basically create a channel, allow you to define some behaviour on item receivers, then close them when the job closes.
So class wise it’s basically just channels with an added on close handler
@Dico it was more about the architecture and patterns than the syntactic sugar.
d
Dico
01/30/2019, 11:22 AM
I mean that the architecture might have evolved differently, impacted by the significant difference in syntactic sugar. But you are right, looking at akka might provide helpful insight.