com.droidkit.actors.ActorContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of actors Show documentation
Show all versions of actors Show documentation
DroidKit Actors is simple actor model implementation for java and Android
package com.droidkit.actors;
/**
* Context of actor
*
* @author Stepan Ex3NDR Korshakov ([email protected])
*/
public class ActorContext {
private final ActorScope actorScope;
/**
* INTERNAL API
* Creating of actor context
*
* @param scope actor scope
*/
public ActorContext(ActorScope scope) {
this.actorScope = scope;
}
/**
* Actor Reference
*
* @return reference
*/
public ActorRef getSelf() {
return actorScope.getActorRef();
}
/**
* Actor system
*
* @return Actor system
*/
public ActorSystem getSystem() {
return actorScope.getActorSystem();
}
/**
* Sender of last received message
*
* @return sender's ActorRef
*/
public ActorRef sender() {
return actorScope.getSender();
}
/**
* Stopping actor
*/
public void stopSelf() {
try {
actorScope.getDispatcher().killGracefully(actorScope);
} catch (Exception e) {
e.printStackTrace();
}
}
}