In folder src/main/java/se/artcomputer/edu/actor there is a gist from
Viktor Klang, a member of Akka project. I have removed some lint.
It is a minimalist Actor implementation. It is for reference only.
From this blog post by Edoardo Vacchi.
Adapted from the blogs ACTORS AND VIRTUAL THREADS, A MATCH MADE IN HEAVEN? and Type You An Actor Runtime For Greater Good!
Demonstrates the use of Virtual Threads to implement an Actor model.
An Actor is a routine and a message queue.
The System puts a message in the Actor's queue. Some time later the Actor gets the chance to read the message and applies the routine.
The routine is called Behavior and takes a message and creates an Effect.
An Effect is the transition to the new state of the Actor, expressed as a new Behavior.
Effect: current Behavior -> new Behavior.
Standard Effects are Stay and Die. Stay means no change while Die is a shutdown of the Actor.
- Build with
mvn package. - Start the server with
sh start-server.sh. - Start clients with
sh start-client.shusername.