Generic base class for reactions. The type parameter T denotes the type of the argument list of the react function that that is applied to when this reaction gets triggered.

Marten Lohstroh marten@berkeley.edu

Type Parameters

Hierarchy (view full)

Constructors

  • Construct a new reaction by passing in a reference to the reactor that will own it, an object to execute the its react and late functions on, a list of triggers, the arguments to pass into react and late, an implementation of this reaction's react function, an optional deadline to be observed, and an optional custom implementation of the late function that is invoked when logical time lags behind physical time with a margin that exceeds the time interval denoted by the deadline.

    Type Parameters

    Parameters

    • reactor: Reactor

      The owner of this reaction.

    • sandbox: ReactionSandbox

      The this object for react and late.

    • trigs: Variable[]

      The ports, actions, or timers, which, when they receive values, will trigger this reaction.

    • args: [...ArgList<T>[]]

      The arguments to be passed to react and late.

    • react: ((...args: ArgList<T>) => void)

      Function that gets execute when triggered and "on time."

        • (...args): void
        • Parameters

          Returns void

    • Optionaldeadline: TimeValue

      The maximum amount by which logical time may lag behind physical time when react has been triggered and is ready to execute.

    • late: ((...args: ArgList<T>) => void) = ...

      Function that gets execute when triggered and "late."

        • (...args): void
        • Parameters

          Returns void

    Returns Procedure<T>

Properties

active: boolean = false

Indicates whether or not this reaction is active. A reaction become active when its container starts up, inactive when its container shuts down.

args: [...ArgList<T>[]]

The arguments to be passed to react and late.

next: undefined | PrioritySetElement<number>

Pointer to the next reaction, used by the runtime when this reaction is staged for execution at the current logical time.

trigs: Variable[]

The ports, actions, or timers, which, when they receive values, will trigger this reaction.

Methods

  • Invoke the react function in the appropriate sandbox and with the argument list that was specified upon the construction of this reaction object.

    Returns void

  • Return the priority of this reaction. It determines the execution order among reactions staged for execution at the same logical time.

    Returns number

  • Return whether or not this reaction has priority over another.

    Parameters

    • another: undefined | PrioritySetElement<number>

      Reaction to compare this reaction's priority against.

    Returns boolean

  • Set a deadline for this reaction. The given time value denotes the maximum allowable amount by which logical time may lag behind physical time at the point that this reaction is ready to execute. If this maximum lag is exceeded, the late function is executed instead of the react function.

    Parameters

    • deadline: TimeValue

      The deadline to set to this reaction.

    Returns this

  • Set for reaction priority, to be used only by the runtime environment. The priority of each reaction is determined on the basis of its dependencies on other reactions.

    Parameters

    • priority: number

      The priority for this reaction.

    Returns void

  • Return whether another, newly staged reaction is equal to this one. Because reactions are just object references, no updating is necessary. Returning true just signals that the scheduler shouldn't stage it twice.

    Parameters

    Returns boolean