tonarino / actor

A minimalist actor framework aiming for high performance and simplicity.
MIT License
40 stars 6 forks source link

spawn_fn_with_addr is not really ergonomic way to create circular actor dependencies #9

Open skywhale opened 3 years ago

strohel commented 3 years ago

I deliberately used circular actor system in the echo example to witness this. It feels less natural than spawning linear actors, but not horrible. It is impossible to "forget about this" as it is otherwise impossible to orchestrate the actors within the type system boundaries.

Only possible mitigation that comes to my mind is to somehow separate the "actor creation phase" from the "actor connecting phase". Maybe by some explicit concept of "connecting" and/or "pads" (output sockets). But that doesn't sound compelling to me. Perhaps spawn_fn_with_addr() is a reasonable price to pay for simplicity of the "normal" case?

I'll stick one possibly related idea to https://github.com/tonarino/actor/issues/10 - did not end up being helpful here.

bschwind commented 3 years ago

One thing I had experimented with in the past was storing actor addresses in a "registry" upfront, and then actors could request an address of a certain actor type via a generic function on System. The downside is you can only have one instantiation of each actor, and the code looked a little clumsy in the "normal" case.