sim.engine
Class WeakStep

java.lang.Object
  extended by sim.engine.WeakStep
All Implemented Interfaces:
java.io.Serializable, Steppable

public class WeakStep
extends java.lang.Object
implements Steppable

WeakStep is a wrapper for steppable objects in the situation where we only want the schedule to tenuously hold onto the steppable object -- that is, if everyone else has forgotten about the object, the schedule should as well. This is commonly the case for inspectors and other kinds of windows which might be closed by the user without any way to get back to the schedule and remove themselves. You schedule a Steppable weakly something like this:
mySchedule.schedule(new WeakStep(mySteppable));

A WeakStep can also wrap a Stoppable you plan on scheduling repeating. You'd do it along these lines:
WeakStep weak = new WeakStep(mySteppable);
Stoppable stop = mySchedule.scheduleRepeating(weak);
weak.setStoppable(stop);
In this case, when the underlying Steppable is garbage-collected, then the schedule will automatically stop repeatedly stepping it.

See Also:
Serialized Form

Field Summary
protected  java.lang.ref.WeakReference weakStep
           
protected  java.lang.ref.WeakReference weakStop
           
 
Constructor Summary
WeakStep(Steppable step)
           
 
Method Summary
 void setStoppable(Stoppable stop)
           
 void step(SimState state)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

weakStep

protected java.lang.ref.WeakReference weakStep

weakStop

protected java.lang.ref.WeakReference weakStop
Constructor Detail

WeakStep

public WeakStep(Steppable step)
Method Detail

setStoppable

public void setStoppable(Stoppable stop)

step

public void step(SimState state)
Specified by:
step in interface Steppable