Package org.jcsp.lang
Class InlineAlternative
- java.lang.Object
-
- org.jcsp.lang.Guard
-
- org.jcsp.lang.InlineAlternative
-
public class InlineAlternative extends Guard
This class is experimental (i.e. not properly documented yet). It is intended to allowAlternatives to be nested.
-
-
Field Summary
Fields Modifier and Type Field Description private AlternativealtIf used as a top level ALT, the work will be delegated to thisprivate intfavouriteIndex to favour (fair / pri)private Guard[]guardThe guardsprivate InlineAlternative[]ialtsNested ALTsprivate longminAlarmShortest alarm set by a timerstatic intMODE_ARBITRARYFlags to control behaviour of this ALT if used as a guard.static intMODE_FAIRFlags to control behaviour of this ALT if used as a guard.static intMODE_PRIFlags to control behaviour of this ALT if used as a guard.private boolean[]preconditionsThe preconditions set for the ALT when it is being used as a guard.private intselectedIndex last selectedprivate intselectModeMode of the selectprivate inttimeoutIndexTimeout indexprivate CSTimer[]timersThe timer guards
-
Constructor Summary
Constructors Constructor Description InlineAlternative(Guard[] guards)Creates a new oneInlineAlternative(Guard[] guards, int mode)Creates a new one
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) booleandisable()Disable this ALT as a guard within its parent ALT.(package private) booleanenable(Alternative alt)Enable this ALT as a guard within its parent ALT.intfairSelect()Creates an Alternative (if needed) and delegates the call to it.GuardgetGuardByIndex(int index)Returns the guard object at a given index.intgetSelected()Returns the index of the guard obtained by a call to select() or if this guard became ready within its parent ALT.GuardgetSelectedGuard()Returns the actual guard object corresponding to the selected guard.intpriSelect()Creates an Alternative (if needed) and delegates the call to it.intselect()Creates an Alternative (if needed) and delegates the call to it.voidsetPreconditionByIndex(int index, boolean on)Alters the precondition on a guard.voidsetPreconditions(boolean[] precons)Establishes a precondition array that will be used by default in calls to select().
-
-
-
Field Detail
-
MODE_ARBITRARY
public static final int MODE_ARBITRARY
Flags to control behaviour of this ALT if used as a guard.- See Also:
- Constant Field Values
-
MODE_FAIR
public static final int MODE_FAIR
Flags to control behaviour of this ALT if used as a guard.- See Also:
- Constant Field Values
-
MODE_PRI
public static final int MODE_PRI
Flags to control behaviour of this ALT if used as a guard.- See Also:
- Constant Field Values
-
alt
private Alternative alt
If used as a top level ALT, the work will be delegated to this
-
selectMode
private int selectMode
Mode of the select
-
selected
private int selected
Index last selected
-
favourite
private int favourite
Index to favour (fair / pri)
-
preconditions
private boolean[] preconditions
The preconditions set for the ALT when it is being used as a guard.
-
guard
private final Guard[] guard
The guards
-
timers
private final CSTimer[] timers
The timer guards
-
ialts
private final InlineAlternative[] ialts
Nested ALTs
-
timeoutIndex
private int timeoutIndex
Timeout index
-
minAlarm
private long minAlarm
Shortest alarm set by a timer
-
-
Method Detail
-
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
public Guard getSelectedGuard()
Returns the actual guard object corresponding to the selected guard. For example it can return the channel or the ALT object.
-
getGuardByIndex
public Guard getGuardByIndex(int index)
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
boolean enable(Alternative alt)
Enable this ALT as a guard within its parent ALT. This will enable all of its guards.
-
-