--- experimental/server/Queue/Queue.java 2001/01/18 22:08:07 1.4 +++ experimental/server/Queue/Queue.java 2001/01/23 20:14:09 1.5 @@ -13,7 +13,7 @@ import uk.ac.ukc.iscream.util.*; * actually contains some elements. * * @author $Author: tdb $ - * @version $Id: Queue.java,v 1.4 2001/01/18 22:08:07 tdb Exp $ + * @version $Id: Queue.java,v 1.5 2001/01/23 20:14:09 tdb Exp $ */ public class Queue { @@ -22,7 +22,7 @@ public class Queue { /** * The current CVS revision of this class */ - public static final String REVISION = "$Revision: 1.4 $"; + public static final String REVISION = "$Revision: 1.5 $"; //---STATIC METHODS--- @@ -88,8 +88,22 @@ public class Queue { } return o; } - + /** + * This method releases a get() method that's currently + * waiting on an empty queue. This was designed for + * shutdown() type methods that may have problems closing + * if the thread of control is waiting on a queue. + * + * @param queue the queue to release + */ + public void releaseQueue(int queue) { + synchronized(((LinkedList) _lists.get(queue))) { + ((LinkedList) _lists.get(queue)).notifyAll(); + } + } + + /** * This method returns a textual status of the queues. It * is merely for observation, and would most likely be used * by a larger "monitoring" component. Information returned @@ -124,10 +138,10 @@ public class Queue { * @return the current size of the queue. */ public int queueSize(int queue) throws InvalidQueueException { - if (queue >= _lists.size() || _lists.get(queue) == null) { + if (queue >= _lists.size() || _lists.get(queue) == null) { throw new InvalidQueueException("Requested queue "+queue+" does not exist"); } - return ((LinkedList) _lists.get(queue)).size(); + return ((LinkedList) _lists.get(queue)).size(); } /** @@ -137,7 +151,7 @@ public class Queue { * @return the element-ometer */ public int elementCount() { - return _count; + return _count; } /**