@FunctionalInterface public interface Process extends Component, CompilableControlFlow
Successive invocations of step(RealtimeContext)
enumerate the
sequence of observable states of this process.
Before step(RealtimeContext)
may be invoked, init()
should be invoked once. The state between the invocations of init()
and step(RealtimeContext)
should not be observed. At any time
between invocations of step(RealtimeContext)
, init()
may be
invoked again to reset the process.
Every entity that implements this interface is assumed to have internal state that conceptually represents a clock index:
-1
by invocation of init()
.step(RealtimeContext)
increases the clock index by
one.init()
and step(RealtimeContext)
is undefined.The clock index is possibly, but not necessarily, proportional to the
amount of model time that has elapsed since initialization. The details are
specified by the objects passed to the step(RealtimeContext)
method.
State transitions are not assumed to be thread-safe. Invocations of
init()
and/or step(RealtimeContext)
should not occur
concurrently or reentrantly.
There is no explicit termination of the lifetime of a process. The
process itself is not entitled to terminate on its own initiative. On the
client side it suffices to cease invoking step(RealtimeContext)
.
RealtimeComponent
Modifier and Type | Interface and Description |
---|---|
static class |
Process.Proxy |
Modifier and Type | Method and Description |
---|---|
default Process |
afterEvery(int delay,
int slowdown,
ConstantRealtimeContext rc) |
default Process |
andThen(Process other)
Composes the state dynamics of this process sequentially with those of
another.
|
default Process |
compile() |
default void |
compileAsMainProcess(CompilationContext context) |
default Consumer<CompilationContext> |
compileControlFlow()
Compiles the state transition of this process.
|
default Consumer<CompilationContext> |
compileInitialization()
Compiles the initialization of this process.
|
default Process |
every(int slowdown,
ConstantRealtimeContext rc) |
default Process |
getProcess()
Deprecated.
|
default boolean |
hasControlFlowIO(CompilationContext context)
Checks whether a compilation context has input/output variables set up for
the compilation of a
step(RealtimeContext) method. |
default boolean |
hasInitializationIO(CompilationContext context)
Checks whether a compilation context has input/output variables set up for
the compilation of an initialization.
|
default void |
init()
Initializes the state of this process.
|
static Process |
probe(Object key) |
static Process |
sequence(List<? extends Process> elems)
Composes the state dynamics of zero or more processes sequentially.
|
static Process |
sequence(Process... elems)
Composes the state dynamics of zero or more processes sequentially.
|
void |
step(RealtimeContext context)
Signals a time event, executing a transition step for this process to the
next observable state.
|
@Deprecated default Process getProcess()
Component
getProcess
in interface Component
default void init()
step(RealtimeContext)
transitions to
the first specified observable state.
The default implementation does nothing.
void step(RealtimeContext context)
The state of the process after successful completion of this method
should be the n-th observable state, if step(eu.bandm.sig.adlib2.RealtimeContext)
has been
invoked n times since the last initialization via init()
.
The behavior of this method is unspecified if init()
has not been
invoked before.
If this method completes abruptly by throwing an error or unchecked exception, the process state should be considered invalid.
context
- the realtime context information for this stepdefault Consumer<CompilationContext> compileInitialization()
This method emits code equivalent to the init()
method of this
component. The compilation context should be set up to specify no input or
output variables.
The default implementation emits code that simply invokes init()
for this process.
This method should be overridden together with compileControlFlow()
, in order to ensure that both operate on the same
state variables.
compileInitialization
in interface CompilableControlFlow
hasInitializationIO(eu.bandm.sig.adlib2.compile.CompilationContext)
default Consumer<CompilationContext> compileControlFlow()
This method emits code equivalent to the step(RealtimeContext)
method of this process. The compilation context should be set up to
specify a single input variable of type RealtimeContext
and no
output variables.
The default implementation emits code that simply invokes step(RealtimeContext)
for this process.
This method should be overridden together with compileInitialization()
, in order to ensure that both operate on the same
state variables.
compileControlFlow
in interface CompilableControlFlow
hasControlFlowIO(eu.bandm.sig.adlib2.compile.CompilationContext)
default boolean hasInitializationIO(CompilationContext context)
context
- the compilation context to be checked
This method is suitable for use in an assert
statement, to be
run at the beginning of the compileInitialization()
method.
compileInitialization()
default boolean hasControlFlowIO(CompilationContext context)
step(RealtimeContext)
method.context
- the compilation context to be checked
This method is suitable for use in an assert
statement, to be
run at the beginning of the compileControlFlow()
method.
compileControlFlow()
default void compileAsMainProcess(CompilationContext context)
default Process andThen(Process other)
Sequential composition means that both processes will be initialized and make transitions at each of the incoming time events together, but at each step this process will observe the non-updated state of the other, whereas conversely the other will already observe the updated state of this process.
other
- the other processstatic Process sequence(Process... elems)
Sequential composition means that all processes will be initialized and make transitions at each of the incoming time events together, but at each step each process will observe the non-updated state of processes occurring later in the sequence, whereas conversely it will already observe the updated state of processes occurring earlier in the sequence.
Behavior is undefined if a process occurs more than once in the sequence.
elems
- the array of processesstatic Process sequence(List<? extends Process> elems)
Sequential composition means that all processes will be initialized and make transitions at each of the incoming time events together, but at each step each process will observe the non-updated state of processes occurring later in the sequence, whereas conversely it will already observe the updated state of processes occurring earlier in the sequence.
Behavior is undefined if a process occurs more than once in the sequence.
elems
- the list of processes@Undocumented static Process probe(Object key)
@Undocumented default Process every(int slowdown, ConstantRealtimeContext rc)
@Undocumented default Process afterEvery(int delay, int slowdown, ConstantRealtimeContext rc)
@Undocumented default Process compile()