The concept of an engine¶
Overview¶
The model of Anoma revolves around the concept of an engine instance, an actor-like entity encapsulating all aspects of a computation process.
An engine has the following components:
- a declaration of a message interface,
- a configuration,
- an environment, and
- a behaviour.
Engines of the same type share the same behaviour. However, two engines of the same type may have different execution context, which in turn may lead to a different message reaction pattern (as "observed" by other engines).
We often write engine, whenever the context makes clear that we refer to a term of an engine type (and not to the type itself), for the sake of brevity.
The type of an engine¶
The type of engines is defined in the engine module. We show the type definition here for convenience.
type Engine C S B H A AM AC AE :=
mkEngine@{
cfg : EngineCfg C;
env : EngineEnv S B H AM;
behaviour : EngineBehaviour C S B H A AM AC AE;
};
Engine components¶
Configuration¶
The configuration of an engine. The data of an engine configuration consists of:
- a parent engine,
- a name,
- a node ID, and
- a generic configuration type
c
.
The complete definition of an engine configuration can be found in the Juvix engine configuration definition.
Environment¶
The execution context of an engine. The data of an engine environment consists of:
- a local state for storing engine-specific data,
- a mailbox cluster for receiving and sending messages,
- a set of acquaintances (other engines that can interact with this engine), and
- a set of active timers.
The complete definition of an engine environment can be found in the Juvix engine environment definition.
Behaviour¶
The function that describes all possible ways in which engines react to messages. This includes:
- modifying their environment,
- sending messages to other engines,
- spawning new engine instances, and
- managing their active timers.
The complete definition of an engine behaviour can be found in the Juvix engine behaviour definition.