edu.vub.at.actors
Interface ActorMirror


 ActorMirror

The class ATActorMirror prescribes the minimal set of methods to be provided by the default implementation of an actor mirror. Since new actor mirrors can be installed dynamically, ATActorMirror defines the dependencies of the lexically scoped objects on the dynamic 'actor context' to perform their duties. The hooks defined in this class relate to:

Author:
smostinc

Field Summary
 ActorMirror getExplicitActorMirror
          def aM := implicitActorMirror.getExplicitActorMirror() This method serves as the 'mirror factory' for explicit actor mirrors.
 
Method Summary
 Object becomeMirroredBy:(ActorMirror protocol)
          def oldprotocol := actor.becomeMirroredBy: newprotocol Installs a new meta-object protocol into this actor.
 Object behaviour()
          Provides access to this actor's "behaviour" object.
 AsyncMessage createMessage(Symbol selector, Table arguments, Table types)
          Creates a first-class message in the language.
 Object createMirror(Object onObject)
          Creates a mirror on the given object.
 Object createReference(Object toObject)
          Create a far reference to a local object.
 Table listIncomingLetters()
          This method provides access to a snapshot of the inbox of an actor.
 Table listPublications()
          This method provides access to a snapshot of the current published services of an actor.
 Table listSubscriptions()
          This method provides access to a snapshot of the current subscriptions of an actor.
 Object provide(TypeTag topic, Object service)
          This mechanism is the most basic mechanism to provide a service.
 Object receive(Object receiver, AsyncMessage message)
          When an actor receives an asynchronous message for a given receiver, it will delegate this to the meta-level 'receive' operation of the designated object.
 Object require(TypeTag topic, Closure handler, Boolean bool)
          This mechanism is the most basic mechanism to require a service.
 Object schedule(Object receiver, AsyncMessage message)
          This mechanism allows for changing the scheduling semantics of the actor's inbox.
 Object send(Object receiver, AsyncMessage message)
          This method implements the default asynchronous message sending semantics for this particular actor.
 Object serve()
          This method fetches and processes the next letter from the inbox.
 
Methods inherited from interface edu.vub.at.objects.Object
super
 

Field Detail

getExplicitActorMirror

ActorMirror getExplicitActorMirror
def aM := implicitActorMirror.getExplicitActorMirror() This method serves as the 'mirror factory' for explicit actor mirrors.

Method Detail

createMessage

AsyncMessage createMessage(Symbol selector,
                           Table arguments,
                           Table types)
Creates a first-class message in the language. Note that upon creation the message does not have a receiver yet. This field will be set once the message is actually being sent, a fact which can be intercepted by overriding the sendTo base-level method.

Parameters:
selector - the name of the method to trigger remotely
arguments - the actual arguments of the message
types - the types with which the message will be born

createMirror

Object createMirror(Object onObject)
Creates a mirror on the given object. This method serves as the 'mirror factory' for the current actor.


send

Object send(Object receiver,
            AsyncMessage message)
This method implements the default asynchronous message sending semantics for this particular actor. In addition to the ability to override the send meta- operation on a single object to have specific adaptions, this hook allows the programmer to modify the message sending semantics for all objects inside an actor. The default implementation ensures the correct passing of messages when they transgress the boundaries of the sending actor.

Throws:
edu.vub.at.exceptions.InterpreterException

receive

Object receive(Object receiver,
               AsyncMessage message)
When an actor receives an asynchronous message for a given receiver, it will delegate this to the meta-level 'receive' operation of the designated object. This operation is introduced as a mechanism to alter the semantics of message reception for all objects contained in an actor. It can be used e.g. to keep track of all succesfully processed messages.


listIncomingLetters

Table listIncomingLetters()
This method provides access to a snapshot of the inbox of an actor. It is however not causally connected to the inbox; adding/removing elements to/from this snapshot will not affect the inbox of the actor.

Returns:
a table containing all letters that are scheduled to be processed

schedule

Object schedule(Object receiver,
                AsyncMessage message)
This mechanism allows for changing the scheduling semantics of the actor's inbox. Note: this method is responsible for calling the serve() method for each scheduled message, which should be executed at a later point in time.

Returns:
a letter, which can be canceled again

serve

Object serve()
This method fetches and processes the next letter from the inbox. It should take into account the possibility that the inbox is empty.


listPublications

Table listPublications()
This method provides access to a snapshot of the current published services of an actor. The result is not causally connected; adding/removing elements to/from this snapshot will not affect the current publications.

Returns:
a table containing all publications of this actor

listSubscriptions

Table listSubscriptions()
This method provides access to a snapshot of the current subscriptions of an actor. The result is not causally connected; adding/removing elements to/from this snapshot will not affect the current subscriptions.

Returns:
a table containing all subscriptions of this actor

provide

Object provide(TypeTag topic,
               Object service)
This mechanism is the most basic mechanism to provide a service. It requires a separate service description and an object offering the service. The return value is a publication object which allows cancelling the service offer.


require

Object require(TypeTag topic,
               Closure handler,
               Boolean bool)
This mechanism is the most basic mechanism to require a service. The return value is a subscription object which allows cancelling the service offer.

Parameters:
bool - - if true, the subscription is permanent, if false, once the subscription has been satisfied, it is automatically cancelled.

createReference

Object createReference(Object toObject)
Create a far reference to a local object. Custom actor mirrors may override this method in order to return different kinds of object references, e.g. leased object references.

Parameters:
toObject - a **near** reference to the object to export
Returns:
a local far reference to the object being exported
Throws:
edu.vub.at.exceptions.XIllegalOperation - if the passed object is a far reference, i.e. non-local

becomeMirroredBy:

Object becomeMirroredBy:(ActorMirror protocol)
def oldprotocol := actor.becomeMirroredBy: newprotocol Installs a new meta-object protocol into this actor.

Parameters:
protocol - meta-level code that overrides an actor's MOP methods
Returns:
the previously installed meta-object protocol

behaviour

Object behaviour()
Provides access to this actor's "behaviour" object. This is the first object created within an actor. Note: if the behaviour is accessed when evaluating the "init.at" initialization file of an actor, the behaviour will not have been initialized yet. It will appear as an empty object.