etomica.action
Class Activity

java.lang.Object
  extended by etomica.action.Activity
All Implemented Interfaces:
IAction, Serializable
Direct Known Subclasses:
ActivityGroupParallel, ActivityGroupSeries, ActivityIntegrate

public abstract class Activity
extends Object
implements IAction, Serializable

An Action that supports the capability of pausing/unpausing and terminating on request. Subclasses define the activity performed by implementing the run() method.

See Also:
Serialized Form

Field Summary
protected  boolean haltRequested
           
protected  boolean isActive
           
protected  boolean pauseRequested
           
 
Constructor Summary
  Activity()
          Create class with a simple default label.
protected Activity(Activity activity)
          Copy constructor.
 
Method Summary
 void actionPerformed()
          Sets integrator to begin isActive on its own thread.
protected  boolean doContinue()
           
protected  void doWait()
          Method to put activity in a condition of being paused.
 void halt()
          Request that the activity terminate as soon as safely possible.
 boolean isActive()
          Indicates if the integrator has been started and has not yet completed.
 boolean isPaused()
          Queries whether the integrator is in a state of being paused.
 void pause()
          Requests that the Activity pause its execution.
protected abstract  void run()
          Method defining the behavior of the activity.
 void unPause()
          Removes activity from the paused state, resuming execution where it left off.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isActive

protected boolean isActive

haltRequested

protected boolean haltRequested

pauseRequested

protected boolean pauseRequested
Constructor Detail

Activity

public Activity()
Create class with a simple default label.


Activity

protected Activity(Activity activity)
Copy constructor.

Method Detail

run

protected abstract void run()
Method defining the behavior of the activity. Implementation should ensure regular checking of doContinue() to permit any requests to pause or halt to be put in effect. If doContinue() returns false, run method should end activity.


actionPerformed

public void actionPerformed()
Sets integrator to begin isActive on its own thread. This is the normal way to begin the integrator's activity. Fires an event to listeners indicating that integrator has started, calls the initialize method, and starts a new thread that then enters the integrators run() method. If integrator is already isActive, method call return immediately and has no effect.

Specified by:
actionPerformed in interface IAction

doContinue

protected boolean doContinue()

doWait

protected void doWait()
Method to put activity in a condition of being paused.


pause

public void pause()
Requests that the Activity pause its execution. The actual suspension of execution occurs only after activity notices the pause request. The calling thread is put in a wait state until the pause takes effect.


unPause

public void unPause()
Removes activity from the paused state, resuming execution where it left off.


halt

public void halt()
Request that the activity terminate as soon as safely possible. Causes calling thread to wait until the halt is in effect.


isPaused

public boolean isPaused()
Queries whether the integrator is in a state of being paused. This may occur independent of whether the integrator is isActive or not. If paused but not isActive, then pause will take effect upon start.


isActive

public boolean isActive()
Indicates if the integrator has been started and has not yet completed. If so, returns true, even if integrator is presently paused (but not halted).