Parallel.addCommands()
method is non-mutating, and returns a new Parallel.
A command can be chained into a Parallel
via the Command.with()
method, this
code snippet is the same as above:
Sequential.addCommands()
method is non-mutating, and returns a new
Sequential.
A command can be chained into a Sequential
via the Command.then()
method,
this code snippet is the same as above:
Parallel
, but Race
finishes as soon as any command
finishes, and Deadline
finishes when the deadline command finishes. This early
end does not interrupt the rest of the unfinished commands.
Mercurial only has one class for both of these: Race
.
deadline
is omitted if it is null.
The Race.addCommands()
and Race.setDeadline()
methods are non-mutating, and
return a new Race.
A command can be chained into a Race
via the Command.raceWith()
method,
this code snippet is the same as above:
Race
as the deadline via the
Command.asDeadline()
method, this code snippet is the same as above:
Race
with a Wait
as the deadline via the
Command.timeout(duration)
method, these two are equivalent:
BooleanSupplier
and a command to run if true
and a command
to run if false
. When the command is initialised it runs the supplier and uses
the result to decide if to run trueCommand
or falseCommand
.
1
, because it always returns true.
The s-expression representation of this command is:
StateMachine
can work with any state type, read more about RefCell
in Util.
Its important to note that StateMachine.withState()
is non-mutating.
Additionally, you must ensure that the StateMachine
never has a state that
doesn’t exist while scheduled, as this will cause it to throw an error.
The name
that is passed to the withState
callback is a preescaped name that
matches the name of the state.
The s-expression representation of this command is:
StateMachine
displays each state-command pair as (state command)
by default,
however, if state and command have the same name, then it just becomes state
,
which we can see above.
schedule()
d again.
This means that if it is bound to a button or similar, it makes it easy to write
some command toggle or state switcher.
In this manner, it acts a bit like Sequential
but does not advance by itself.
At the same time, it is a bit like a rudimentary StateMachine
.
advancing
command itself before
Advancing.advance()
will have affect again.
The s-expression representation of this command is: