edu.ksu.cis.cadena.core.queue
Class ModelChangeQueue

java.lang.Object
  extended by edu.ksu.cis.cadena.core.queue.ModelChangeQueue
All Implemented Interfaces:
java.lang.Runnable

public class ModelChangeQueue
extends java.lang.Object
implements java.lang.Runnable


Constructor Summary
ModelChangeQueue(AdaptingResourceSetImpl resourceSet)
          Default constructor.
 
Method Summary
 void addErrorListener(IModelChangeQueueErrorListener listener)
           
 void addListener(IModelChangeQueueListener listener)
          Adds a change queue listener.
 void enqueAction(IModelChangeAction action)
          Adds an action to the actions list.
 boolean isRunning()
           
 boolean isWorkerThread()
          Determine whether or not the current active thread is the worker thread.
 void removeErrorListener(IModelChangeQueueErrorListener listener)
           
 void removeListener(IModelChangeQueueListener listener)
          Removes a change qeue listener.
 void run()
          The main work loop.
 void start()
          Starts the change queue.
 void stopQueue(boolean wait)
          Stops the change queue.
 void wait(IModelChangeAction action)
          Waits on an action to be completed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelChangeQueue

public ModelChangeQueue(AdaptingResourceSetImpl resourceSet)
Default constructor.

Parameters:
resourceSet - The resource set that this queue is "working" for. Must not be null.
Method Detail

start

public void start()
Starts the change queue. If the queue is already running, this method does nothing. After this method is called, the queue will be running.


stopQueue

public void stopQueue(boolean wait)
Stops the change queue. The list of enqueued actions is not cleared. If an action is currently running, it is allowed to finish.

Parameters:
wait - If true, this method will block until the work queue has died.

isRunning

public boolean isRunning()
Returns:
true if the queue is running, false otherwise.

isWorkerThread

public boolean isWorkerThread()
Determine whether or not the current active thread is the worker thread.

Returns:
true if the current thread is indeed the worker thread. false otherwise.

run

public void run()
The main work loop. This should not be called outside of this class.

Specified by:
run in interface java.lang.Runnable

enqueAction

public void enqueAction(IModelChangeAction action)
Adds an action to the actions list.

Parameters:
action - The action to add.

wait

public void wait(IModelChangeAction action)
Waits on an action to be completed. If the action is not in the queue, or the action has already run, the method returns immeadiately.

Parameters:
action - The action to wait on.

addListener

public void addListener(IModelChangeQueueListener listener)
Adds a change queue listener. Does nothing if the listener has already been added.

Parameters:
listener - The listener to add.

removeListener

public void removeListener(IModelChangeQueueListener listener)
Removes a change qeue listener. Does nothing if the listener is not in the list.

Parameters:
listener - The listener to remove.

addErrorListener

public void addErrorListener(IModelChangeQueueErrorListener listener)

removeErrorListener

public void removeErrorListener(IModelChangeQueueErrorListener listener)