autohit.vm
Class VMAutomat

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--autohit.vm.VMAutomat

public class VMAutomat
extends java.lang.Thread

A VM automat. This is a different kind of VM context. Basically, it accepts a queue through which it can be controlled. Send it a Sim to run or an Integer(VM.STATE_*) to effect the state. NOTE that these are "requests." There is no guarentee that the order will be followed.

Here is a state diagram which shows some off the effects of control "requests." kill() is a special case, where another thread calls the Automat's kill() method.

                  | RUNNING      | PAUSED       | NO_VM 
  A VM            | ignored      | ignored      | vm is run
  STATE_NEW       | ignored      | ignored      | ignored
  STATE_RUNNING   | ignored      | vm paused    | ignored
  STATE_PAUSED    | vm resumed   | ignored      | ignored
  STATE_DONE      | vm discarded | vm discarded | ignored
  STATE_NO_VM     | ignored      | ignored      | ignored
  die()          | <---  VM Killed and Automat dies ------>  
 


Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
VMAutomat(LockedQueue controlQueue)
          Constructor.
 
Method Summary
 int getLastKnownStatus()
          Return the last known stable status.
 void kill(LockedQueue controlQueue)
          Kills the Automat as soon as possible.
 void run()
          Run the automat
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VMAutomat

public VMAutomat(LockedQueue controlQueue)
Constructor.
Method Detail

getLastKnownStatus

public int getLastKnownStatus()
Return the last known stable status. This is not 100% accurate, as the automate MAY be in the process of shifting status while this is being queried. It should be close enough for most purposes; the window of possible inaccuracy is perdy small... This method can be called by any thread.
Returns:
a VM.STATUS_* int value.
See Also:
VM

kill

public void kill(LockedQueue controlQueue)
Kills the Automat as soon as possible.

run

public void run()
Run the automat
Overrides:
run in class java.lang.Thread