Methods Summary |
---|
public void | abort()
this.closed = this.aborted = true;
synchronized (list) {
list.notifyAll();
}
|
public void | add(int index, java.lang.Object object)Add the job at the specified position. Probably based on priority?
if (closed)
throw new QueueClosedException("Queue closed.");
synchronized (list) {
if (list.size() >= limit) {
throw new TooManyTasksException("Too many tasks in queue...");
}
list.add(index, object);
list.notify();
}
|
public void | addAll(java.util.Collection c)Appends all of the elements in the specified collection to the end of
this list, in the order that they are returned by the specified
collection's iterator.
if (closed)
throw new QueueClosedException("Queue closed.");
synchronized (list) {
if (list.size() >= limit) {
throw new TooManyTasksException("Too many tasks in queue...");
}
list.addAll(c);
list.notify();
}
|
public void | addFirst(java.lang.Object object)Add to the head of the queue. Probably a high priority job?
if (closed)
throw new QueueClosedException("Queue closed.");
synchronized (list) {
if (list.size() >= limit) {
throw new TooManyTasksException("Too many tasks in queue...");
}
list.addFirst(object);
list.notify();
}
|
public void | addLast(java.lang.Object object)Add to the tail of the queue.
if (closed)
throw new QueueClosedException("Queue closed.");
synchronized (list) {
if (list.size() >= limit) {
throw new TooManyTasksException("Too many tasks in queue...");
}
list.add(object);
list.notify();
}
|
public int | getUnsyncSize()Return the size of the queue, unsynchronized method.
return list.size();
|
public int | getUnsyncWaitingThreads()Return the number of waiting Threads on the queue.
return waiters;
|
public java.lang.Object | remove(boolean canWait)Remove a task from the queue. If there are no objects then the thread blocks. The thread
will be notified if any object is added to the queue.
while (true) {
if (aborted) {
throw new QueueClosedException("Queue closed....");
}
synchronized (list) {
if (list.size() > 0) {
//System.out.println(Thread.currentThread().getName() + ": GOT SOME TASK!!....");
//Bug 4677074 begin
//_logger.log(Level.FINE,Thread.currentThread().getName() + ": GOT SOME TASK!!....");
//Bug 4677074 end
return list.removeFirst();
}
if (closed) {
throw new QueueClosedException("Queue closed....");
} else {
if (! canWait) {
return null;
}
//System.out.println(Thread.currentThread().getName() + ": waiting....");
//Bug 4677074 begin
//_logger.log(Level.FINE,Thread.currentThread().getName() + ": waiting....");
//Bug 4677074 end
waiters++; // added for 4682740
list.wait();
waiters--; // added for 4682740
}
}
}
|
public java.lang.Object | remove(long waitFor)Remove a task from the queue. If there are no objects then the thread blocks. The thread
will be notified if any object is added to the queue.
// Fixed for Bug No. 4673949
if (aborted) {
throw new QueueClosedException("Queue closed....");
}
synchronized (list) {
if (list.size() > 0) {
//System.out.println(Thread.currentThread().getName() + ": GOT SOME TASK!!....");
//Bug 4677074 begin
//_logger.log(Level.FINE,Thread.currentThread().getName() + ": GOT SOME TASK!!....");
//Bug 4677074 end
return list.removeFirst();
}
if (closed) {
throw new QueueClosedException("Queue closed....");
} else {
waiters++; // added for 4682740
list.wait(waitFor);
waiters--; // added for 4682740
if (list.size() > 0) {
//System.out.println(Thread.currentThread().getName() + ": GOT SOME TASK!!....");
//Bug 4677074 begin
//_logger.log(Level.FINE,Thread.currentThread().getName() + ": GOT SOME TASK!!....");
//Bug 4677074 end
return list.removeFirst();
} else {
// We timed out
return null;
}
}
} //Synchronized list
|
public void | shutdown()
this.closed = true;
synchronized (list) {
list.notifyAll();
}
|
public int | size()
synchronized (list) {
return list.size();
}
|
public java.lang.String | toString()Return a String with information about this queue. Good for monitoring.
StringBuffer sb = new StringBuffer();
sb.append("BlockingQueue [TW=").append(waiters);
sb.append(", CS=").append(list.size());
sb.append(", MS=").append(limit).append("]");
return sb.toString();
|