com.objectwave.appArch
Class Queue

java.lang.Object
  |
  +--com.objectwave.appArch.Queue
All Implemented Interfaces:
java.lang.Runnable

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

An event queue. Can be used for threadsave serial execution of events. Queue elements are added to the queue and when the queue element's turn is up, the queue element is notified that it is time to execute.

Author:
Dave Hoag
See Also:
QueueElement

Field Summary
 boolean alive
           
 
Constructor Summary
Queue()
           
 
Method Summary
 void bind(QueueElement element)
          Wake us up if we are waiting.
 java.lang.Thread getThread()
           
 void loopForBinding()
          Wait until an event is place on queue.
 void processQueue()
           
 void run()
           
 void setUpProcessQueue()
          We need very few synchronized methods with this implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alive

public boolean alive
Constructor Detail

Queue

public Queue()
Method Detail

bind

public void bind(QueueElement element)
          throws java.io.IOException
Wake us up if we are waiting. If not waiting, then just add the element to our growing wait list of elements (queues). If the element is null, it means that we should setup our process queue and began executing.

java.io.IOException

getThread

public java.lang.Thread getThread()

loopForBinding

public void loopForBinding()
Wait until an event is place on queue.


processQueue

public void processQueue()

run

public void run()
Specified by:
run in interface java.lang.Runnable

setUpProcessQueue

public void setUpProcessQueue()
We need very few synchronized methods with this implementation. A call to this will copy the current queue to the working queue. This will be an ordered list of events. The processing of the queue can then execute unsynchronized until all elements in the queue have been processed.