Class Actor

java.lang.Object
org.semispace.actor.Actor

public abstract class Actor extends Object
Implementation of an actor. You need to register the actor in a space, in order to get a lifetime of the actor. The read and take templates are registered at this time as well.
  • Constructor Details

    • Actor

      public Actor()
  • Method Details

    • getDefaultLifeMsOfSpaceObject

      public long getDefaultLifeMsOfSpaceObject()
    • setDefaultLifeMsOfSpaceObject

      public void setDefaultLifeMsOfSpaceObject(long defaultLifeMsOfSpaceObject)
      How long a message will live in the space when it is sent.
    • register

      public final void register(SemiSpaceInterface registerWith)
      Register with the space with a very long long actor life. Useful when you are actively using unregister, or expect the actor to live longer than the VM itself.
      See Also:
    • register

      public final void register(SemiSpaceInterface registerWith, long actorLifeMs)
      You must register with a space in order to activate the actor.
      Parameters:
      actorLifeMs - How long the actor shall be active in milliseconds
      See Also:
    • unregister

      public void unregister()
      Removing the connection(s) from the space rendering the actor, for all practical purposes, dead.
    • send

      public void send(Object obj)
      Send two message to the space. The first is the object to write, the other is the manifest for the message, which can be used by the listening actor to find the originator. This method is intended only to be used when initiating an actor dialog, as the destination is unknown
    • send

      public void send(Long destinationId, Object payload)
      This is the regular method for sending a message to an actor. The message will be delivered directly to the indicated actor. No of the parameters may be null.
      Parameters:
      destinationId - When replying to a message, the originatorId should be the destination id. i.e. the destination address
    • getActorId

      public Long getActorId()
      Returns:
      Id of this actor provided that it is registered in a space.
    • getTakeTemplates

      public Object[] getTakeTemplates()
      Default implementation which renders an empty array, ie nothing is tried taken. Exchange with relevant elements. Object are tried taken from the space. Observe that the object taken is the one that fits the template, and not necessarily the one which triggered the event.
    • getReadTemplates

      public Object[] getReadTemplates()
      Default implementation which renders empty array, ie nothing is tried read.
      See Also:
    • receive

      public abstract void receive(ActorMessage msg)
      Receive a message which either matches the template, or that is addressed to this actor in particular (which implies that you need to check the type for each message).