edu.princeton.toy.lang
Interface TVirtualMachine.ExecutionController

All Known Implementing Classes:
TFrame
Enclosing class:
TVirtualMachine

public static interface TVirtualMachine.ExecutionController

ExecutionController is an interface that classes which wish to recieve notifications of a ToyVirtualMachine's termination should implement.

See Also:
TVirtualMachine.run(TVirtualMachine.ExecutionController)

Method Summary
 int getClockPeriod()
          This function is called by the TVirtualMachine's runner after it has recieved an order for a batch of steps to be run.
 int statusUpdate(TVirtualMachine virtualMachine, int n, int elapsedTime, boolean willStop)
          This function is called by the TVirtualMachine's runner when it has completed the previous batch of steps.
 

Method Detail

statusUpdate

int statusUpdate(TVirtualMachine virtualMachine,
                 int n,
                 int elapsedTime,
                 boolean willStop)
This function is called by the TVirtualMachine's runner when it has completed the previous batch of steps.

Parameters:
virtualMachine - The virtual machine whose status is being reported.
n - The number of steps taken since the last update.
elapsedTime - The number of milliseconds between the lastUpdate and the present.
willStop - Wheter or not the TVirtualMachine will stop after this status update.
Returns:
The number of additional steps to take before fireing more ChangeEvents and producing another status update. If this is 0, the virtualMachine will stop. If this is negative, a stack trace will be written to stderr and the virtualMachine will stop.

getClockPeriod

int getClockPeriod()
This function is called by the TVirtualMachine's runner after it has recieved an order for a batch of steps to be run. The next status update will not occur until after n * getClockPeriod() milliseconds, where n was the number of steps taken. If the preferred clock period is too fast, the next status update will occur as soon the batch of steps is completed.

Returns:
The preferred number of milliseconds each step should take.