public interface LongClockedSignalSource extends LongSignalSource, AbstractClockedSignalSource
long
whose observable state is
driven by a clock.
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 = ...; LongClockedSignalSource c = ...; c.init(); while (...) { c.step(rc); long v = c.getAsLong(); ... }
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
Modifier and Type | Interface and Description |
---|---|
static class |
LongClockedSignalSource.AbstractRandom |
Process.Proxy
STREAM_CHARACTERISTICS, STREAM_SIZE
Modifier and Type | Method and Description |
---|---|
static LongClockedSignalSource |
adHoc(long... elems)
Returns a new signal source that produces the given values, one per clock tick.
|
default LongClockedSignalSource |
after(Process... slaves) |
default LongClockedSignalSource |
compile()
Returns a new signal source that realizes the same behavior as this signal
source with specialized code.
|
static LongClockedSignalSource |
count(long from)
Returns a new signal source whose value increases by one at every clock
tick.
|
static LongClockedSignalSource |
countdown(long from)
Returns a new signal source whose value decreases by one at every clock
tick.
|
static LongClockedSignalSource |
cycle(long... elems)
Returns a new signal source that produces the given values repeatedly, one
per clock tick.
|
static LongClockedSignalSourceFraction |
dt(Optional<ConstantRealtimeContext> rc) |
default LongClockedSignalSource |
during(Register outer) |
static LongClockedSignalSource |
ofSpliterator(Supplier<? extends Spliterator.OfLong> spliterator,
LongSupplier afterwards) |
static LongClockedSignalSource |
ofStream(Supplier<? extends LongStream> stream) |
static LongClockedSignalSource |
ofStream(Supplier<? extends LongStream> stream,
LongSupplier afterwards) |
static LongClockedSignalSource |
random() |
static LongClockedSignalSource |
random(long seed) |
static LongClockedSignalSource |
random(OptionalLong seed) |
default Spliterator.OfLong |
spliterator(Supplier<? extends RealtimeContext> context) |
default LongStream |
stream(Supplier<? extends RealtimeContext> context) |
abs, add, choose, choose, choose, choose, clock, compileDataFlow, compileMainSignalSource, constant, delayed, delayed, delayedFeedback, delayedFeedback, divide, equal, getAsLong, getConstantAsLong, getValueClass, greaterOrEqual, greaterThan, guard, hasConstantAsLong, invariant, lessOrEqual, lessThan, map, max, min, modulo, multiply, negate, negative, nonEqual, nonnegative, nonpositive, nonzero, positive, power, probe, publishStoredValueVariable, relateWith, sampleAndHold, stored, subtract, zero, zipWith
compileDataFlowTo, hasDataFlowIO
afterEvery, andThen, compileAsMainProcess, compileControlFlow, compileInitialization, every, getProcess, hasControlFlowIO, hasInitializationIO, init, probe, sequence, sequence, step
default LongClockedSignalSource after(Process... slaves)
default LongClockedSignalSource during(Register outer)
@SafeVarargs static LongClockedSignalSource adHoc(long... 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.getAsLong() == (n <
elems.length ? elems[n] : 0l)
holds.
elems
- the array of values to produce@SafeVarargs static LongClockedSignalSource cycle(long... elems)
When the given values are exhausted the iteration starts over.
At clock index n
, this.getAsLong() == elems[n %
elems.length]
holds.
elems
- the array of values to producedefault LongClockedSignalSource 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 LongStream stream(Supplier<? extends RealtimeContext> context)
default Spliterator.OfLong spliterator(Supplier<? extends RealtimeContext> context)
static LongClockedSignalSource ofStream(Supplier<? extends LongStream> stream)
static LongClockedSignalSource ofStream(Supplier<? extends LongStream> stream, LongSupplier afterwards)
static LongClockedSignalSource ofSpliterator(Supplier<? extends Spliterator.OfLong> spliterator, LongSupplier afterwards)
static LongClockedSignalSource count(long from)
Initialization resets the value to the given initial value.
At clock index n
, this.getAsLong() == from + n
holds.
from
- the value at the first clock tick after initializationstatic LongClockedSignalSource countdown(long from)
Initialization resets the value to the given initial value.
At clock index n
, this.getAsLong() == Math.max(from
- n, 0)
holds.
from
- the value at the first clock tick after initializationIllegalArgumentException
- if from
is negativestatic LongClockedSignalSourceFraction dt(Optional<ConstantRealtimeContext> rc)
@Undocumented static LongClockedSignalSource random(long seed)
@Undocumented static LongClockedSignalSource random()
@Undocumented static LongClockedSignalSource random(OptionalLong seed)