AggregateContext

class AggregateContext(localId: ID, messages: Collection<InboundMessage>, previousState: Set<State<*>>)

Context for managing aggregate computation. It represents the localId of the device, the messages received from the neighbours, and the previousState of the device.

Constructors

Link copied to clipboard
constructor(localId: ID, messages: Collection<InboundMessage>, previousState: Set<State<*>>)

Functions

Link copied to clipboard
fun <R> alignedOn(pivot: Any?, body: () -> R): R

Alignment function that pushes in the stack the pivot, executes the body and pop the last element of the stack after it is called. Returns the body's return element.

Link copied to clipboard
fun <X> exchange(initial: X, body: (Field<X>) -> Field<X>): Field<X>

This function computes the local value of e_i, substituting variable n with the nvalue w of messages received from neighbours, using the local value of e_i (initial) as a default. The exchange returns the neighbouring or local value v_r from the evaluation of e_r applied to the body. e_s evaluates to a nvalue w_s consisting of local values to be sent to neighbour devices δ′, which will use their corresponding w_s(δ') as soon as they wake up and perform their next execution round.

Link copied to clipboard

Messages to send to the other nodes.

Link copied to clipboard

Observes the value of an expression type across neighbours.

Link copied to clipboard
fun newState(): Set<State<*>>

Return the current state of the device as a new state.

Link copied to clipboard
fun <X, Y> repeating(initial: X, repeat: (X) -> Y): Y

Iteratively updates the value of the input expression repeat at each device using the last computed value or the initial.

Link copied to clipboard
fun <Initial> AggregateContext.share(initial: Initial, transform: (Field<Initial>) -> Initial): Initial

share captures the space-time nature of field computation through observation of neighbours' values, starting from an initial value, it reduces to a single local value given a transform function and updating and sharing to neighbours of a local variable.

Link copied to clipboard

sharing captures the space-time nature of field computation through observation of neighbours' values, starting from an initial value, it reduces to a single local value given a transform function and updating and sharing to neighbours of a local variable.