ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/server/Queue/Queue.java
(Generate patch)

Comparing experimental/server/Queue/Queue.java (file contents):
Revision 1.3 by tdb, Tue Jan 2 01:50:17 2001 UTC vs.
Revision 1.4 by tdb, Thu Jan 18 22:08:07 2001 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2 + package uk.ac.ukc.iscream.util;
3  
4   //---IMPORTS---
5   import java.util.LinkedList;
6   import java.util.NoSuchElementException;
7 < //import uk.ac.ukc.iscream.util.*;
7 > import uk.ac.ukc.iscream.util.*;
8  
9   /**
10   * A Queue class designed to operate in a multi-threaded environment, with
# Line 14 | Line 15 | import java.util.NoSuchElementException;
15   * @author  $Author$
16   * @version $Id$
17   */
18 < class Queue {
18 > public class Queue {
19  
20   //---FINAL ATTRIBUTES---
21  
# Line 115 | Line 116 | class Queue {
116      }
117      
118      /**
119 +     * Returns the size of a given queue. A consumer can use
120 +     * this to see how big their queue is at any given time.
121 +     * they should use their queue number as the parameter.
122 +     *
123 +     * @param queue The queue number to query.
124 +     * @return the current size of the queue.
125 +     */
126 +    public int queueSize(int queue) throws InvalidQueueException {
127 +        if (queue >= _lists.size() || _lists.get(queue) == null) {
128 +            throw new InvalidQueueException("Requested queue "+queue+" does not exist");
129 +        }
130 +        return ((LinkedList) _lists.get(queue)).size();
131 +    }
132 +    
133 +    /**
134 +     * Returns the total numer of elements to have passed
135 +     * through this queue (ie. a counter on the add method).
136 +     *
137 +     * @return the element-ometer
138 +     */
139 +    public int elementCount() {
140 +        return _count;
141 +    }
142 +    
143 +    /**
144       * This method assigns a queue to a consumer. The idea behind
145       * this is to ensure that only 1 consumer can be associated with
146       * a given queue, otherwise the whole "blocking" thing fails
# Line 162 | Line 188 | class Queue {
188       *
189       * @return the name of this class and its CVS revision
190       */
191 <    /*public String toString() {
191 >    public String toString() {
192          return FormatName.getName(
193              _name,
194              getClass().getName(),
195              REVISION);
196 <    }*/
196 >    }
197  
198   //---PRIVATE METHODS---
199  
# Line 195 | Line 221 | class Queue {
221       * can be placed here.  This name could also
222       * be changed to null for utility classes.
223       */
224 <    //private String _name = <!THIS SHOULD CALL A STATIC NAME IN THE COMPONENT CLASS FOR THIS OBJECT!>;
199 <
200 <    /**
201 <     * This holds a reference to the
202 <     * system logger that is being used.
203 <     */
204 <    //private Logger _logger = ReferenceManager.getInstance().getLogger();
224 >    private String _name = null;
225  
226   //---STATIC ATTRIBUTES---
227  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines