← Dialogue Documentation Home

Dialogue.Company

Company Overview

The company provides a clear tree structure for scoping messages between actors. The Company also handles the actual instances of the actors and gives each actor a unique id for accessing those instances.


Tree

The company is simply a tree of actors. Other than the root actor, every actor has a parent. Each parent can have any number of children.

Since Dialogue is meant to operate in an asynchronous fashion through messages, the company tree can be changed while operating on any given actor. For example, an actor can be sent a message and removed from the company at the same time. The company accomplishes this by separating the structure of the tree from each actor instance.

The company also has the concept of benched actors which are actors that have been temporarily removed from the tree. Because they are benched from the tree, they won't be recipients of messages sent through tones. Benched actors still have their instances handled by the company and can be referenced directly by their unique ids. Benching an actor is useful for runtime debugging and re-structuring of the tree. See actor:bench to bench an actor and actor:join to join it back to the tree.

↑ top


Instances

The company creates and handles the instance returned from the actor constructor. This means that the company handles the lifetimes of the actors and that those lifetimes aren't associated with the objects returned from the actor constructor. See actor:remove to destroy these instances.

The company gives a unique integer id to each of those instances so they may be referenced throughout. These ids can also reference the same actors through runs of the program as long as the tree's structure remains the same and that the actors which comprise the tree are created in the same order.

Ids of -1 are not unique and are Dialogue's null id. Coming across an id of -1 should indicate "no actor" or "bad actor" depending on the context.

↑ top