vendredi 23 décembre 2022

How do I design an Actor model?

I am trying to implement an Actor model in Java.

I have started with the following class diagram.

As you can see, the ActorRunner created in the ActorContext is responsible for controlling the life cycle of the actors: it has the message queue and it calls the process() method of the actor for each received message in its loop (run()). Actors simply implement the Actor interface with the single process() method.

Now, I want to add a decorator (Decorator pattern) and be able to decorate the send() and process() methods. However, since the Actor interface does not have the send() I cannot decorate it and spawn a decorated actor with ActorContext.spawnActor().

How can I modify the design to suit my needs?

Aucun commentaire:

Enregistrer un commentaire