share

inline fun <ID : Any, Shared> Aggregate<ID>.share(initial: Shared, noinline body: (Field<ID, Shared>) -> Shared): Shared

share implements efficient stateful data sharing.

Namely, starting from an initial value of Shared, it computes a Field of Shared, which is fed to the body function, and the resulting Shared is then stored internally and sent to all neighbors.

Results are Aggregate.evolved across rounds, namely, this function also stores the returned value as state, and later invocations in successive rounds will not start from the provided initial value, rather, from the previously computed result.