larzactor
The actor model.
Lightweight actors with mailboxes on threads, tell/ask messaging and supervision — concurrency by message passing instead of shared state and locks.
larzscript pkg install actor
What you get
- Mailbox actors on threads
- tell / ask messaging
- Supervision
- No shared-state locks
Try it
import "actor" as actor
let counter = actor.spawn(fn(state, msg) {
if msg["op"] == "add" { return {"state": state + msg["n"]} }
if msg["op"] == "get" { return {"state": state, "reply": state} }
}, 0)
actor.tell(counter, {"op": "add", "n": 5})
actor.run(counter)
print(actor.ask(counter, {"op": "get"}))Output
5
Why it's in the Larz Stack
larzactor is a real Larzscript package (larzscript pkg install actor) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.