Package org.jcsp.lang
Class InlineAlternative
java.lang.Object
org.jcsp.lang.Guard
org.jcsp.lang.InlineAlternative
This class is experimental (i.e. not properly documented yet).
It is intended to allow
Alternative
s to be nested.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Alternative
If used as a top level ALT, the work will be delegated to thisprivate int
Index to favour (fair / pri)private final Guard[]
The guardsprivate final InlineAlternative[]
Nested ALTsprivate long
Shortest alarm set by a timerstatic final int
Flags to control behaviour of this ALT if used as a guard.static final int
Flags to control behaviour of this ALT if used as a guard.static final int
Flags to control behaviour of this ALT if used as a guard.private boolean[]
The preconditions set for the ALT when it is being used as a guard.private int
Index last selectedprivate int
Mode of the selectprivate int
Timeout indexprivate final CSTimer[]
The timer guards -
Constructor Summary
ConstructorsConstructorDescriptionInlineAlternative
(Guard[] guards) Creates a new oneInlineAlternative
(Guard[] guards, int mode) Creates a new one -
Method Summary
Modifier and TypeMethodDescription(package private) boolean
disable()
Disable this ALT as a guard within its parent ALT.(package private) boolean
enable
(Alternative alt) Enable this ALT as a guard within its parent ALT.int
Creates an Alternative (if needed) and delegates the call to it.getGuardByIndex
(int index) Returns the guard object at a given index.int
Returns the index of the guard obtained by a call to select() or if this guard became ready within its parent ALT.Returns the actual guard object corresponding to the selected guard.int
Creates an Alternative (if needed) and delegates the call to it.int
select()
Creates an Alternative (if needed) and delegates the call to it.void
setPreconditionByIndex
(int index, boolean on) Alters the precondition on a guard.void
setPreconditions
(boolean[] precons) Establishes a precondition array that will be used by default in calls to select().
-
Field Details
-
MODE_ARBITRARY
public static final int MODE_ARBITRARYFlags to control behaviour of this ALT if used as a guard.- See Also:
-
MODE_FAIR
public static final int MODE_FAIRFlags to control behaviour of this ALT if used as a guard.- See Also:
-
MODE_PRI
public static final int MODE_PRIFlags to control behaviour of this ALT if used as a guard.- See Also:
-
alt
If used as a top level ALT, the work will be delegated to this -
selectMode
private int selectModeMode of the select -
selected
private int selectedIndex last selected -
favourite
private int favouriteIndex to favour (fair / pri) -
preconditions
private boolean[] preconditionsThe preconditions set for the ALT when it is being used as a guard. -
guard
The guards -
timers
The timer guards -
ialts
Nested ALTs -
timeoutIndex
private int timeoutIndexTimeout index -
minAlarm
private long minAlarmShortest alarm set by a timer
-
-
Constructor Details
-
InlineAlternative
Creates a new one -
InlineAlternative
Creates a new one
-
-
Method Details
-
getSelected
public int getSelected()Returns the index of the guard obtained by a call to select() or if this guard became ready within its parent ALT. -
setPreconditions
public void setPreconditions(boolean[] precons) Establishes a precondition array that will be used by default in calls to select(). This is useful when the ALT is used as a guard within another ALT. -
setPreconditionByIndex
public void setPreconditionByIndex(int index, boolean on) Alters the precondition on a guard. -
getSelectedGuard
Returns the actual guard object corresponding to the selected guard. For example it can return the channel or the ALT object. -
getGuardByIndex
Returns the guard object at a given index. For example to obtain a channel or ALT object. -
select
public int select()Creates an Alternative (if needed) and delegates the call to it. -
priSelect
public int priSelect()Creates an Alternative (if needed) and delegates the call to it. -
fairSelect
public int fairSelect()Creates an Alternative (if needed) and delegates the call to it. -
enable
Enable this ALT as a guard within its parent ALT. This will enable all of its guards. -
disable
boolean disable()Disable this ALT as a guard within its parent ALT. This will disable all of its guards.
-