You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ra...@apache.org on 2002/04/26 16:31:20 UTC
cvs commit: jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/util Queue.java
rana_b 02/04/26 07:31:20
Modified: ftpserver/src/java/org/apache/avalon/ftpserver/util
Queue.java
Log:
queue max limit added
Revision Changes Path
1.4 +24 -5 jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/util/Queue.java
Index: Queue.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/util/Queue.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Queue.java 6 Mar 2002 13:42:57 -0000 1.3
+++ Queue.java 26 Apr 2002 14:31:20 -0000 1.4
@@ -1,3 +1,4 @@
+// $Id: Queue.java,v 1.4 2002/04/26 14:31:20 rana_b Exp $
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
@@ -26,6 +27,7 @@
private LinkedList mList = new LinkedList();
private boolean mbWait;
+ private int miMaxSize = 0;
/**
* Constructor.
@@ -42,7 +44,7 @@
*/
public synchronized Object get() {
if(mbWait) {
- while(isEmpty()) {
+ while(mList.size() == 0) {
try {
wait();
}
@@ -64,8 +66,11 @@
if(obj == null) {
throw new NullPointerException("Queue element cannot be null");
}
- mList.addFirst(obj);
- notifyAll();
+
+ if (miMaxSize <= 0 || mList.size() < miMaxSize) {
+ mList.addFirst(obj);
+ notifyAll();
+ }
}
/**
@@ -76,10 +81,24 @@
}
/**
+ * Get max size
+ */
+ public int getMaxSize() {
+ return miMaxSize;
+ }
+
+ /**
+ * Set max size
+ */
+ public void setMaxSize(int maxSize) {
+ miMaxSize = maxSize;
+ }
+
+ /**
* Is the list empty (size == 0)
*/
public synchronized boolean isEmpty() {
- return size() == 0;
+ return mList.size() == 0;
}
/**
@@ -88,4 +107,4 @@
public synchronized void clear() {
mList.clear();
}
-}
\ No newline at end of file
+}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>