|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.ac.man.cs.rainbow.simulator.RainbowThread
Superclass of all Rainbow threads. Threads are schedulable objects that are used to implement the behaviour of the Rainbow system for simulation and state enumeration (for deadlock and temporal model checking.)
Scheduler
,
Rainbow Implementors GuideInner Class Summary | |
static class |
RainbowThread.IllegalChannelStateException
Indicate an attempt to do something naughty with a channel. |
static class |
RainbowThread.IllegalThreadTerminationException
Indicate an attempt to do exit a top-level thread. |
static class |
RainbowThread.SavedRainbowThreadState
For saving our state. |
Field Summary | |
static int |
AFTER_CHOICE
Used to indicate (in some cases) that the thread is executing immediately after making a non-deterministic choice. |
static int |
BACKWARD
Used to indicate that the thread is executing backwards. |
static int |
FORWARD
Used to indicate that the thread is executing forwards. |
static int |
INITIALISE
Used to indicate that the thread is initialising itself. |
protected Scheduler |
scheduler
This thread's scheduler. |
Constructor Summary | |
RainbowThread(RainbowThread parent)
Create a new thread that is a child of the given thread. |
|
RainbowThread(Scheduler scheduler)
Create a new top-level thread in the given scheduler. |
Method Summary | |
abstract Data |
characterise()
Characterise this thread. |
boolean |
choice(int choiceRange)
Request a non-deterministic choice. |
boolean |
delay(int delay)
Request that this thread should be delayed for a bit. |
protected abstract void |
execute()
Make this thread execute in the current direction. |
void |
execute(int direction)
Make this thread execute in the specified direction. |
void |
exitSelf()
Make the current thread terminate. |
int |
getChoice()
What non-deterministic choice was taken? |
int |
getChoiceRange()
Over what values should a non-deterministic choice be made? |
int |
getDirection()
What direction is this thread executing in? |
Data |
getFromChannel(Channel chan)
Read a value off a channel. |
RainbowThread |
getParent()
Get this thread's parent thread. |
boolean |
isAvailable(Channel chan)
Test whether the given channel is available. |
void |
loadState(SavedState saved)
Reload a previously saved state. |
void |
putToChannel(Channel chan,
Data value)
Put a value onto a channel. |
boolean |
release(Channel chan)
Release the given channel. |
SavedState |
saveState()
Save the state of this thread. |
protected RainbowThread |
scheduleChild(RainbowThread child)
Schedule the thread for execution. |
protected void |
setChoice(int choice)
Set what non-deterministic choice was taken. |
boolean |
signalForward(Channel chan)
Attempt to transfer the value currently on the channel to the other end. |
void |
sleep()
Mark this thread as wanting to yield. |
boolean |
stillBusy(Channel chan)
Test to see if the target end has finished reading from the channel. |
String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int FORWARD
execute(int)
public static final int BACKWARD
execute(int)
public static final int INITIALISE
execute(int)
,
Scheduler.initialise()
public static final int AFTER_CHOICE
execute(int)
,
NDChoice
,
StateEnumerator
protected Scheduler scheduler
Constructor Detail |
public RainbowThread(Scheduler scheduler)
scheduler
- The scheduler that will schedule the created thread.public RainbowThread(RainbowThread parent)
parent
- The thread that the created thread will be a child of.Method Detail |
public final void execute(int direction) throws RainbowException
direction
- Which direction to execute in.RainbowException
- If something goes wrong during the thread's execution.FORWARD
,
BACKWARD
,
INITIALISE
,
execute()
protected abstract void execute() throws RainbowException
RainbowException
- If something goes wrong during the thread's execution.execute(int)
,
getDirection()
public abstract Data characterise()
StateEnumerator.characterise(Data[])
protected void setChoice(int choice)
Scheduler
public int getChoice()
public int getChoiceRange()
public int getDirection()
FORWARD
,
BACKWARD
,
INITIALISE
,
AFTER_CHOICE
public RainbowThread getParent()
public final Data getFromChannel(Channel chan) throws RASMThread.Exception
RainbowThread.IllegalChannelStateException
- If the channel is not activated.Channel.getContents()
,
Get
public final void putToChannel(Channel chan, Data value) throws RASMThread.Exception
RainbowThread.IllegalChannelStateException
- If the channel is activated.Channel.setContents(Data)
,
Put
public final boolean signalForward(Channel chan)
Scheduler
,
SignalForward
public final boolean stillBusy(Channel chan)
WaitRelease
public final boolean isAvailable(Channel chan)
chan
- The channel to test for availability.getFromChannel(Channel)
,
release(Channel)
,
IsAvailable
public final boolean release(Channel chan)
chan
- The channel to release.Release
public final void sleep()
public final boolean delay(int delay)
delay
- How long to delay the thread for.IllegalArgumentException
- If the delay is less than zero.public final boolean choice(int choiceRange)
choiceRange
- One more than the maximum value that can be chosen (the
minimum is 0)public final void exitSelf() throws RainbowException
RainbowException
- If this thread is a top-level thread.protected final RainbowThread scheduleChild(RainbowThread child)
child
- The thread to schedule. Must be a child of this thread.public SavedState saveState()
StateEnumerator.saveState()
,
loadState(SavedState)
public void loadState(SavedState saved)
saved
- The saved state token to reload.IllegalArgumentException
- If the state token was not created by this thread.StateEnumerator.restoreState(SavedState)
,
saveState()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |