Skip to content

Instantly share code, notes, and snippets.

@rikkimax
Last active August 29, 2015 13:58
Show Gist options
  • Save rikkimax/9969536 to your computer and use it in GitHub Desktop.
Save rikkimax/9969536 to your computer and use it in GitHub Desktop.

Dakka is an actor based framework in the idea of Akka.

Descriptions

  • An actor can be located any where.
    An actor in of itself is unique per the location.
    Please note that any two are not the same but are very similar.
  • The closest actor to the present actor should be used when referencing.
    If this is local in the same location or in another it doesn't matter.
  • An actor knows who's near it (supervisor and children).
    But it doesn't know the message its getting.
module dakka.test.example;
import dakka.base.defs;
shared class Adder : Actor {
this(shared(Actor) supervisor = null) {
super(supervisor);
}
int add(int x, int y) {
return x + y;
}
void check(bool go) {
assert(add(100, 5) == 105);
}
}
shared class AdderUser : Actor {
private {
Adder adder;
}
this(shared(Actor) supervisor = null) {
super(supervisor);
adder = actorOf!Adder;
}
override void onStart() {
assert(adder.add(1, 2) == 3);
adder.check(true);
}
}
void main() {
auto user = new shared ActorRef!AdderUser();
user.onStart();
import vibe.d : runEventLoop;
runEventLoop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment