HomeReferenceDomain.h ⇀ MakeContinuation

MakeContinuation function

Syntax

// (1)
template
<
    typename D,
    typename D2 = D,
    typename S,
    typename FIn
>
Continuation<D,D2> MakeContinuation(const Signal<D,S>& trigger, FIn&& func);

// (2)
template
<
    typename D,
    typename D2 = D,
    typename E,
    typename FIn
>
Continuation<D,D2> MakeContinuation(const Events<D,E>& trigger, FIn&& func);

// (3)
template
<
    typename D,
    typename D2 = D,
    typename E,
    typename FIn,
    typename ... TDepValues
>
Continuation<D,D2>
    MakeContinuation(const Events<D,E>& trigger,
                     const SignalPack<D,TDepValues...>& depPack, FIn&& func);

// (4)
template
<
    typename D,
    typename D2 = D,
    typename S,
    typename FIn
>
Continuation<D,D2> MakeContinuation(TransactionFlagsT flags, const Signal<D,S>& trigger, FIn&& func);

// (5)
template
<
    typename D,
    typename D2 = D,
    typename E,
    typename FIn
>
Continuation<D,D2> MakeContinuation(TransactionFlagsT flags, const Events<D,E>& trigger, FIn&& func);

// (6)
template
<
    typename D,
    typename D2 = D,
    typename E,
    typename FIn,
    typename ... TDepValues
>
Continuation<D,D2>
    MakeContinuation(TransactionFlagsT flags, const Events<D,E>& trigger,
                     const SignalPack<D,TDepValues...>& depPack, FIn&& func);

Semantics

(1) When the signal value s of trigger changes, func(s) is queued as an asynchrounous transaction of domain D2. In pseudo code:

AsyncTransaction<D2>([func, s] {
    func(s)
});

(2) For every event e in trigger, func(e) is called in an asynchronous transaction of domain D2. Multiple events from the same turn are captured in a single transaction. In pseudo code:

AsyncTransaction<D2>([func, events] {
    for (const auto& e : events)
        func(e);
});

(3) Similar to (2), but the synchronized values of signals in depPack are passed to func as additional arguments. Changes of signals in depPack do not trigger an update - only received events do. In pseudo code:

AsyncTransaction<D2>([func, events, depValues...] {
    for (const auto& e : events)
        func(e, depValues ...);
});

The signature of func should be equivalent to:

(4,5,6) behave similar to (1,2,3), respectively, but allow to specify the flags that are used for the continuation transaction.

The event parameter const E& can also be replaced by an event range, i.e. void func(EventRange<E> range, const TDepValues& ...) for case (3). This allows for explicit batch processing of events of a single turn.

The initiating transaction is only complete, when all its continuations are complete, i.e. DoTransaction will block, and AsyncContinuation passes on its TransactionStatus to all continuation transactions. Waiting on continuations does not occupy the engine; other transactions can already start running and continuations can bounce back and forth between domains without blocking each other.