Skip to content
Juvix preamble

module arch.node.engines.ticker;

import prelude open;
import arch.node.types.engine_environment open;
import arch.node.types.engine_behaviour open;
import arch.node.types.engine open;
import arch.node.engines.ticker_messages open public;
import arch.node.engines.ticker_environment open public;
import arch.node.engines.ticker_behaviour open public;

open ticker_environment_example;

Ticker Engine

The Ticker engine provides a simple counter functionality, allowing clients to increment a counter and retrieve its current value.

Purpose

A ticker engine maintains a counter in its local state. It increases the counter when it receives an Increment message and provides the updated result upon receiving a Count message. The initial state initializes the counter.

Components

Type

TickerEngine : Type :=
Engine
TickerLocalState
TickerMailboxState
TickerTimerHandle
TickerMatchableArgument
TickerActionLabel
TickerPrecomputationList;

Example of a ticker engine

exampleTickerEngine : TickerEngine :=
mkEngine@{
name := "ticker";
behaviour := tickerBehaviour;
initEnv := zeroTickerEnvironment
};

where zeroTickerEnvironment is defined as follows:

zeroTickerEnvironment : TickerEnvironment :=
mkEngineEnvironment@{
name := "ticker";
localState :=
mkTickerLocalState@{
counter := 0;
};
mailboxCluster := Map.empty;
acquaintances := Set.empty;
timers := [];
};
(Wiki) links on this page