// // GenericSwarm -- object to coordinate a collection of started activities // @deftype GenericSwarm <ActionPlan, TimeIndexing, GetOwner, CREATABLE> SETTING - setSwarmObjects: aCollection; USING - getSwarmObjects; - getSwarmActivity; - getSubswarms; @end // // ActivationOrder -- default concurrent group type for swarm // @deftype ActivationOrder <ActionGroup, CREATABLE> @end
GenericSwarm is the type of an object that can be activated to run in some context, and which itself then defines a context in which other action plans can be activated. Subtypes of this generic type can each define a custom interface to activities running within the swarm. The generic swarm type defines only access to an underlying activity that keeps track of the activated or running subactivities, along with an option that may be set to a collection of objects currently being processed by the swarm.
If subactivities running within a swarm are indexed by time (running either schedules or other swarms), the default coordination performed by the swarm is to merge all the different scheduled actions so that the actions of one time value are all performed before the actions of any later time value. If the actions are not indexed by time, or if an subactivity has been released from strict time synchronization with other subactivities in the swarm, the default coordination is limited to partial order constraints among the action plans being run. (.. Currently only the merging of schedules and subswarms by time values is supported.)
A public superclass called Swarm is supplied in the swarmobject library for use in implementing custom swarm classes. Such a class can override the activateIn: message defined by ActionPlan to automatically start subactivities to run within a swarm when the swarm is first activated.
@deftype GenericSwarm <ActionPlan, TimeIndexing, GetOwner, CREATABLE>GenericSwarm inherits the messages of both ActionPlan and TimeIndexing. The getOwner message defined by GetOwner is also inherited.
The default value for the ConcurrentGroupType option of TimeIndexing is not a generic action group, but a special predefined subtype of ActionGroup called ActivationOrder. This concurrent group type guarantees that actions scheduled to occur at the same time from different action plans running in the same swarm are executed in the same order in which the action plans were first activated.
SETTING - setSwarmObjects: aCollection; USING - getSwarmObjects;
- getSwarmActivity; - getSubswarms;getSwarmActivity returns the activity which is currently the running of subactivities within the swarm. This activity is the same as the value returned by activateIn: when the swarm was first activated. It returns nil if the swarm has not yet been activated.
Unlike other action plans, swarms and swarm activities always exist in a one-to-one relationship, provided that a swarm activity has been created yet. This restriction to a single action plan enables the swarm to do double-duty as a custom object that provides its own support and interface to the activities running within the swarm.
Swarms run in a tree of current activations just like all other activities. The inherited getOwner message returns the containing swarm in which the local swarm is currently running. getSubswarms returns a collection of other swarms that are running within the local swarm. The collections that define the swarm activation tree are automatically maintained as new swarms are activated and old ones completed.