bquarp v0.5.1 Reactivity.DSL.Signal View Source

The DSL for Distributed Reactive Programming, specifically, operations applicable to Signals in general (both Behaviours and Event Streams).

Link to this section Summary

Functions

Attaches a new Guarantee to the Signal.

Checks if the given Signal carries the given Guarantee (among others, possibly).

Clears all Guarantees of the given Signal.

Returns the type of the given signal

Returns the Guarantees of the given Signal.

Gets the node where the signal with the given name is hosted.

Inspects the given Signal by printing its output Values to the console.

Inspects the given Signal by printing its Messages to the console.

Checks whether the given object is a signal.

Keeps the given Guarantee as the only Guarantee of the given Signal. Removes all other Guarantees.

Lifts and applies an n-ary primitive function to n Signals.

Lifts a primitive function that operates on lists of any size and applies it to a list of Signals (either all Event Streams or all Behaviours), which can be subject to change as Signals drop out and new ones are supplied by a higher-order Event Stream.

Publishes a Signal by registering it in the Registry.

Removes the given Guarantee from the given Signal. Leaves the Signal alone if the Guarantee is not present.

Sets the given Guarantee as the only guarantee for the given Signal.

Gets a Signal from the Registry by its name.

Gets the names, types and hosts of all the available signals.

Transforms a Signal into a plain Observable.

Transforms a Signal into a Signal Observable.

Unregisters a Signal from the Registry by its name.

Link to this section Functions

Attaches a new Guarantee to the Signal.

The Signal may already possess one or more Guarantees. The new Guarantee is simply added.

Link to this function

carries_guarantee?(arg, g) View Source

Checks if the given Signal carries the given Guarantee (among others, possibly).

Clears all Guarantees of the given Signal.

Returns the type of the given signal

Returns the Guarantees of the given Signal.

Gets the node where the signal with the given name is hosted.

Inspects the given Signal by printing its output Values to the console.

Inspects the given Signal by printing its Messages to the console.

Checks whether the given object is a signal.

Link to this function

keep_guarantee(arg1, gt) View Source

Keeps the given Guarantee as the only Guarantee of the given Signal. Removes all other Guarantees.

Lifts and applies an n-ary primitive function to n Signals.

Takes:

  • A list of n input Signals, each with an associated set of Guarantees.
  • An n-ary primitive function Returns:
  • An output Signal that is the result of the lifting of the primitive function and its subsequent application to the input Signals.

Output for the resulting Signal is only created if a newly received message from an input Signal can be combined with the rest of the buffer under the Guarantees of the different Signals.

The resulting Guarantees of the output Signal are a combination of the Guarantee sets of the input Signals.

When combining:

  • Behaviours:

    • The output signal is a Behaviour.

      • They have their last values kept as state until a more recent one is used.
      • Each value is regarded as an update that may trigger a new output.
      • This is similar to 'combineLatest' in Reactive Extensions.
  • With Event Streams:

    • The output Signal is an Event Stream
    • They have their used values kept only until they can be combined, at which point they are removed so they can't be used more than once.
    • Each value is regarded as a time series data point, which needs to be combined with corresponding data points in other time series and popagated thereafter

      • This is similar to 'Zip' in Reactive Extensions.
  • Both Behaviours and Event Streams

    • The output Signal is an Event Stream

      • New output is triggered by events from the Event Streams.
      • New values of behaviours are kept as state to be combined with. They will not however trigger an update.
      • The first value of a Behaviour can however trigger a series of outputs if there is an event history that has been waiting for this value to combine.
      • This is similar to 'combineLatestSilent' (with buffered propagation) in Reactive Extensions (specifically in the Observables Extended library)

E.g.: c = a + b (with a, b and the resulting c all having Behaviours without guarantee)

a: 5 --------------------------------- 1 -->
b: ------------- 3 --------- 5 ------------>

c: -------------- 8 --------- 10 ------ 6 ->

E.g.: c = a + b (with a Behaviour and b an Event Stream, both without Guarantee, and the resulting c an Event Stream without, guarantee as well)

a:  5 ------------------------------------ 1
b:  ------------- 3 ------ 5 -------------->

c:  -------------- 8 ------ 10 ------------>

E.g.: c = a + b (with a, b and the resulting c all Event Streams without Guarantee)

a: 5 --------------------------------- 1 -->
b: ------------- 3 ---- 5 ----------------->

c: -------------- 8 ------------------- 6 ->

E.g.: c = a + b (with a, b and the resulting c all Event Streams under {:t, 0} = strict time-synchronization)

a: 5(2) ----------- 3(3} -------------- 1(4) -------------->
b: ---------- 4(1) ------------ 5(2) -------------- 3(3) -->

c: ----------------------------- 10(2) --------------6(3) ->

E.g.: c = a + b (with a, b and the resulting c all Event Streams under {:t, 1} = relaxed time-synchronization)

a: 5(2) -------------- 3(3} ------------- 1(4) ------------>
b: ---------- 4(1) -------------- 5(2) ------------- 3(3) ->

c: ----------- 9(1,2) ------------- 8(2,3) ---------- 4(3,4)

E.g.: c = a + b (with a, b and the resulting c all Behaviours under {:c, 0} = strict causality)

a: 5(x2,y2) --------------------------------------- 2(x3,y3)
b: -------- 3(x1) ---- 3(x2) --- 8(x3) --- 7(x4) ---------->

c: -------------------- 8(..) --- 13(..) --- 12(..) -- 9(..)

(For more information: consult the DREAM academic paper by Salvaneschi et al.)

E.g.: d = a + b + c (with a, b, c and the resulting d Behaviours under {:g, 0} = strict glitch freedom)

a: 5(x2) ---------------------------------------- 2(x3) --->
b: ----- 3(x1) ------ 3(x2) -- 8(x3) ---------------------->
c: ------------ 7(y5) -------------- 4(y6)----------------->

d: ------------------- 15(x2,y5) ---- 12(x2,y6) -- 14(x3,y6)

(For more information: consult the QUARP and/or DREAM academic paper)

E.g.: d = a + b + c (with a, b Behaviours under {:g, 0}, c an Event Stream under {:t, 0} and the resulting d an Event Stream with [{:g, 0}, {:t, 0}] as Guarantees)

a: 5(x2) --------------------------------------------- 2(x3)
b: ------- 3(x1) ---------- 3(x2) --- 8(x3) --------------->
c: --------------- 7(5) --------------------- 4(6) -------->

d: ------------------------- 15(x2,5) -------- 12(x2,6) --->

E.g.: c = a + b (with a an Event Stream under [{:g, 0}, {:t, 0}], b a Behaviour under {:g, 0} and the resulting c an Event Stream having [{:g, 0}, {:t, 0}] for Guarantees)

a: 5(x2,1) ---------------------- 7(x2,2) -------- 6(x2,3)->
b: ------- 3(x1) ---- 4(x2) --------------- 7(x3) --------->

c: ------------------- 9(x2,1) --- 11(x2,2) ------- 10(x2,3)
Link to this function

liftapp_var(ss, arg, func) View Source

Lifts a primitive function that operates on lists of any size and applies it to a list of Signals (either all Event Streams or all Behaviours), which can be subject to change as Signals drop out and new ones are supplied by a higher-order Event Stream.

Takes:

* A list of Signals, each carrying the same Guarantees gs.
* A higher-order Event Stream carrying new Signals with Guarantees gs.
* A function operating on lists of values of any size.

Returns

  • An output Signal that is the result of the lifting of the primitive function and its subsequent application to the input Signals. The output Signal has the same type as the input Signals (either Behaviour or Event Stream)

For behaviours: E.g.: br = List.sum(bs) / length(bs) (without Guarantee) and eh a higher-order Event Stream carrying new Behaviours.

eh: ----------------- b3 --------------------- b4 -------->
b1: 5 ------------------------------///////////////////////
b2: ------------- 3 ----------------------- 5 ------------>
b3: //////////////////------ 7 --------------------------->
b4: ////////////////////////////////////////////---- 3 --->
...
br :-------------- 4 -------- 5 ------------ 6 ------ 5 -->

For event streams: E.g.: er = List.sum(es) / length(es) (without Guarantee) and eh a higher-order Event Stream carrying new Event Streams.

eh: ----------------- e3 --------------------- e4 -------------->
e1: 5 ---------------------------- 4 --- 5 -/////////////////////
e2: ------------- 3 ------------ 4 ----------- 5 ----------- 4 ->
e3: //////////////////------ 7 ------------ 5 -------- 4 ------->
e4: ///////////////////////////////////////////////////////---- 1
...
er :-------------- 4 ------------- 5 --------- 5 ------ 5 ----- 3

Publishes a Signal by registering it in the Registry.

Link to this function

remove_guarantee(arg1, gt) View Source

Removes the given Guarantee from the given Signal. Leaves the Signal alone if the Guarantee is not present.

Sets the given Guarantee as the only guarantee for the given Signal.

This can be considered the creation of a new source Signal from another Signal in a stratified dependency graph.

Gets a Signal from the Registry by its name.

Gets the names, types and hosts of all the available signals.

Transforms a Signal into a plain Observable.

The Context is stripped from each Signal Message

Transforms a Signal into a Signal Observable.

Both the Value and Context {v, c} of each Signal Message are preserved.

Unregisters a Signal from the Registry by its name.