A
- the type of values produced by this signal sourcepublic interface ClockedSignalSource<A> extends SignalSource<A>, AbstractClockedSignalSource
This interface excludes signal sources whose state changes asynchronously, but is neutral with respect to whether values are computed on the fly when demanded, or stored when available and then just retrieved.
The operation of the driving clock works as specified by the Process
superinterface. For example, a main loop may use the following
pattern:
RealtimeContext rc = ...; ClockedSignalSource c = ...; c.init(); while (...) { c.step(rc); A v = c.get(); ... }
Every iteration of the main loop increases the clock index of the
component c
. The behavior of instances of this interface is
typically specified in terms of the current clock index.
Process
Process.Proxy
STREAM_CHARACTERISTICS, STREAM_SIZE
Modifier and Type | Method and Description |
---|---|
static <A> ClockedSignalSource<A> |
adHoc(Class<? super A> valueClass,
A... elems)
Returns a new signal source that produces the given values, one per clock tick.
|
default ClockedSignalSource<A> |
after(Process... slaves) |
default ClockedSignalSource<A> |
compile()
Returns a new signal source that realizes the same behavior as this signal
source with specialized code.
|
static <A> ClockedSignalSource<A> |
cycle(Class<? super A> valueClass,
A... elems)
Returns a new signal source that produces the given values repeatedly, one
per clock tick.
|
default ClockedSignalSource<A> |
during(Register outer) |
static <A> ClockedSignalSource<A> |
ofSpliterator(Class<A> valueClass,
Supplier<? extends Spliterator<A>> spliterator,
Supplier<? extends A> afterwards) |
static <A> ClockedSignalSource<A> |
ofStream(Class<A> valueClass,
Supplier<? extends Stream<A>> stream) |
static <A> ClockedSignalSource<A> |
ofStream(Class<A> valueClass,
Supplier<? extends Stream<A>> stream,
Supplier<? extends A> afterwards) |
default Spliterator<A> |
spliterator(Supplier<? extends RealtimeContext> context) |
default Stream<A> |
stream(Supplier<? extends RealtimeContext> context) |
choose, choose, choose, choose, clock, compileDataFlow, compileMainSignalSource, constant, constant, delayed, delayed, delayedFeedback, delayedFeedback, eq, get, getConstant, getValueClass, guard, hasConstant, invariant, map, map, neq, power, probe, publishStoredValueVariable, relateWith, sampleAndHold, stored, zipWith
compileDataFlowTo, hasDataFlowIO
afterEvery, andThen, compileAsMainProcess, compileControlFlow, compileInitialization, every, getProcess, hasControlFlowIO, hasInitializationIO, init, probe, sequence, sequence, step
default ClockedSignalSource<A> after(Process... slaves)
default ClockedSignalSource<A> during(Register outer)
@SafeVarargs static <A> ClockedSignalSource<A> adHoc(Class<? super A> valueClass, A... elems)
After the given values are exhausted, that is after as many clock ticks as there are elements in the array, the default value of the element type is held indefinitely.
At clock index n
, this.get() == (n <
elems.length ? elems[n] : null)
holds.
A
- the type of values produced by this signal sourceelems
- the array of values to produce@SafeVarargs static <A> ClockedSignalSource<A> cycle(Class<? super A> valueClass, A... elems)
When the given values are exhausted the iteration starts over.
At clock index n
, this.get() == elems[n %
elems.length]
holds.
A
- the type of values produced by this signal sourceelems
- the array of values to producedefault ClockedSignalSource<A> compile()
The resulting object displays the same long-term behavior (reaction with output values to realtime events) as this signal source. Its internal state is undefined phase until initialized properly.
Specialized JVM byte code is generated, and a new class is loaded for the implementation. It can be expected to execute more efficiently than the original after a warm-up phase, subject to the usual conditions of JVM just-in-time compilation. Hence compilation is recommended for components to be used in tight long-running loops, but not for one-off or infrequent computations.
The original and the compiled instance do not share state phase or memory; their life cycles are independent except for shared non-compilable components. For the latter reason, it is recommended not to use both instances concurrently.
default Stream<A> stream(Supplier<? extends RealtimeContext> context)
default Spliterator<A> spliterator(Supplier<? extends RealtimeContext> context)
static <A> ClockedSignalSource<A> ofStream(Class<A> valueClass, Supplier<? extends Stream<A>> stream)
static <A> ClockedSignalSource<A> ofStream(Class<A> valueClass, Supplier<? extends Stream<A>> stream, Supplier<? extends A> afterwards)
static <A> ClockedSignalSource<A> ofSpliterator(Class<A> valueClass, Supplier<? extends Spliterator<A>> spliterator, Supplier<? extends A> afterwards)