fdeantoni / tiny-tokio-actor

A simple tiny actor library on top of Tokio
Apache License 2.0
67 stars 10 forks source link

Should be message oriented #8

Open frehberg opened 1 year ago

frehberg commented 1 year ago

Right now the Actor framework is method oriented, the ActorRef is generalizing over the ActorImpl ActorRef<ActorImpl>, this is causing design-problems if one wants to store different ActorRefs over different ActorImpls in a single container. The intention of the container is to sent the same message to each one.

Instead of ActorRef<ActorImpl> the framework should use references being message oriented, such as Slot<MessageType>

Lets call this proxy (channel::tx) Slot for now.

The function create_actor() might return a single slot or multiple slots, for example

let (slot_msg_type1, slot_msg_type2) : (Slot<MsgType1>, Slot<MsgType2>) = create_actor(MyActorImpl::new(x,y,z))?;
fdeantoni commented 1 year ago

Thanks for this issue @frehberg! Its a problem that has vexed me for some time. I was thinking perhaps this could be solved though enums generated by a macro, similar to inventory but I havent had the chance to look into this in more detail...