28: Sending an Agent on a Trip
- Preparing a ticket
- A ticket defines an agent's trip by the ticket's attributes.
- It identifies the agent's destination with a teleaddress, telename, type of class at destination.
- It specifies the permits it desires at its destination.
- It lists the way to get to the destination.
- It gives maximum and desired times for the trip's duration, after which (for maximum time) the ticket expires.
- It carries notes about the trip (useful for clones, described later).
- A ticket can carry nil values for any of these attributes, so it's possible for a ticket to be highly detailed, to have just one or a few details, or to carry no information whatsoever (in which case it's useless).
- If a ticket has a destination class type but no telename, it can't specify travel to another engine becuase the finder at the destination doesn't know about class names.
- Sending an agent
- The agent's go operation takes a ticket as an argument and sends the agent on a trip to the specified destination.
- The agent's send operation takes a list of tickets as an argument. It creates a clone of the agent, one for each ticket, and sends the clone agents on simultaneous trips to the destinations specified in the ticket.
- The ticket for each clone can contain individual instructions for the clone in its notes attribute. These may be executed in the clone's live method or simply referred to to see what the clone was supposed to do.
- When an agent travels, execution stops, its state is saved, the agent is encoded, placed in an envelope, and sent to its destination. The agent's ticket is part of the envelope so receiving engines can get pertinent routing information.
- When the encoded agent arrives in a new region, the region may change the regional permit of the agent.
- When an agent enters a destination place through a successful call of entering on the place, the agent is decoded, its state is restored, and it continues execution from the point where it stopped.
- When entering is called on a place to admit an agent, the operation may reset the local permit of the agent before the agent resumes execution.
- A ticket is satisfied by any place that matches the specified name, address, and class within the maximum duration.
- If a ticket is flexible enough to be satisfied by more than one place, the engine may approach each place in turn until one admits the agent. (Admission is determined when the engine calls entering on the place and identifies the agent wishing to enter.)
- If a ticket isn't satisfied by any existing place, or if all satisfactory places reject the agent, the telesphere rejects the ticket and the agent is sent back to its origin.
- Why an agent may not be able to travel (a cursory look at process control)
- An agent, while it's in a place, may make procedure calls on outside objects and processes (objects and processes that aren't part of the agent). (Process control is described in detail in the multitasking chapter.)
- If the agent is still engaged in operations on outside objects and processes, it can't travel because those objects and processes won't be available when it awakens at its location.
- An agent must be in full control (not engaged in external operations) before it can travel, or its go or send operation will throw a ProcessNotControlled exception.
- An external object may call an operation on an agent that contains *.go. The agent can't go unless the agent calls the operation on itself.
- Specifying an Agent's Route: Ways and Means
- A ticket may supply a Way object to specify an agent's route to its destination.
- A Way object contains three attributes:
- An authenticator that contains a telename used to authenticate the object as it passes through regions in the course of a trip.
- An entity, the telename of the agent.
- A means that identifies a means of communication such as phone lines. (Means is an abstract class, so you must use a concrete subclass such as ExistingConnectionMeans.)
- Creating reservable means
- The ReservableMeans mix-in allows you to create a Means subclass that can be reserved.
- Reserving a means asks the engine to keep a connection open and ready for an upcoming trip. It's no guarantee that the connection will be open. (Typically used for an agent coming from a Magic Cap device to say "keep the line up, I'm coming back." If the agent doesn't come up before the time limit, the line is dropped.)
- Using existing connection means
- The ExistingConnectionMeans class represents a reservable means for a connection already created for a trip. This object records the route back over a connection for an agent's return trip.
- Agent duplication
- An agent may be accidentally duplicated when it travels (duplicate packets, for example).
- Whenever an agent travels, its "isPossibleDuplicate" attribute may be set to True if the agent had to be retransmitted.
- Processes dealing with an agent may check its isPossibleDuplicate attribute and take actions as they see fit for an agent that is a possible duplicate.
- Branding a Process
- A process (agent) visiting a region can create other processes while there. Brands help keep track of those processes.
- The engine assigns a brand to an agent when it enters a region.
- The brand is stored in the regionalData attribute of the process. There is no Brand class; a brand can be any kind of object.
- If a process creates any other processes while it's in the region, the process's brand is given to each process it creates.
- Any process can get the brand of any other process.
- A process with the authority of the region can set the brand of any process.
TS Ref - 26 JUN 1996
Generated by the sweat of Mike Boom's brow.