Sending messages to self |
Category: |
Modeling
Purpose: |
Describe techniques for defining actor behavior which can trigger itself
Intended Audience: |
All ObjecTime developers
Applicable to: |
All Versions
Description: |
Under rare circumstances an actor may need to send a message to itself in order to force itself to change states. This note explains some techniques which can be used to do this.
Before considering doing this, keep in mind that this will couple the detail code of a transition to the high level state machine. This coupling can make future maintenance of the actor difficult. For example, a minor change to the actor's state machine (behavior) may cause the system to break since the internal transition has been coded based on knowledge of the current state machine's structure.
One solution is to have two ports bound to each other on the same actor. These ports could be internal ports or interface ports. Both kinds of ports could be connected together (normal rules for binding compatibility apply). The message will be delivered by the run-time system just as any other actor-actor message.
Another is to use the Timing Service to send a timeout message to the actor. The interval can be set to zero to effectively place the message immediately on the queue.
Limitations: |
Directly exerting control over the state machine from within the detail code may make maintenance of the state machine more difficult.
Consider other design strategies first.
See also: |
None
Copyright © 1999, ObjecTime Limited. |