Class Actor
java.lang.Object
org.semispace.actor.Actor
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongObject[]Default implementation which renders empty array, ie nothing is tried read.Object[]Default implementation which renders an empty array, ie nothing is tried taken.abstract voidreceive(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).final voidregister(SemiSpaceInterface registerWith) Register with the space with a very long long actor life.final voidregister(SemiSpaceInterface registerWith, long actorLifeMs) You must register with a space in order to activate the actor.voidThis is the regular method for sending a message to an actor.voidSend two message to the space.voidsetDefaultLifeMsOfSpaceObject(long defaultLifeMsOfSpaceObject) How long a message will live in the space when it is sent.voidRemoving the connection(s) from the space rendering the actor, for all practical purposes, dead.
-
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
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
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
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
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
- Returns:
- Id of this actor provided that it is registered in a space.
-
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
Default implementation which renders empty array, ie nothing is tried read.- See Also:
-
receive
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).
-