|
Oracle Internet Directory API Reference 11g Release 1 (11.1.1) E10664-01 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.ldap.util.WorkQueue
public class WorkQueue
This class implements a queue whose elements are added based on a priority. The minimum priority is 1 and the maximum priority by default is 1. Elements are added to this Q based on the specified priority.
For e.x .... WorkQueue m_jobQ = new WorkQueue(5); ... Will create a Queue object which can hold elements of 5 different priorities. |- - - - | - Priority 5 elements will be added here |- - - - | - Priority 4 .. |- - - - | - Priority 3 .. |- - - - | - Priority 2 .. |- - - - | - Priority 1 ..
When the queue is closed, new elements could not be added to it. However DeQueue should be possible if there are any elements left in it. When there are no elements in the Queue and it is closed and if dequeueing operation is performed then it will throw a QClosedException
When a thread tries to dequeue an element and if there are no elements in the queue it will wait until an element is added to the queue. However if the queue is closed, it will return QClosedException
The highest priority element and the one that was added first will be dequeued. If there are no elements in that priority list then next lower priority list will be considered for dequeuing
QClosedException
Constructor Summary | |
---|---|
WorkQueue() Default Constructor. |
|
WorkQueue(int nMaxPriority) Constructor to create a queue, whose elements are classified into a given number of priority types. |
|
WorkQueue(int nMaxElements, int nMaxPriority) Constructor to create a queue which has a limit on upper bound and also the maximum number of priority types it can hold. |
Method Summary | |
---|---|
void |
close() Use this method to close the queue. |
java.lang.Object |
dequeue() |
java.lang.Object |
dequeue(java.util.logging.Logger lgr) Dequeues an object. |
java.lang.Object |
dequeueNoWait() Dequeues an object from the queue but does not wait if the Q is empty. |
void |
enqueue(java.lang.Object obj) |
void |
enqueue(java.lang.Object obj, int priority) |
void |
enqueue(java.lang.Object obj, int priority, java.util.logging.Logger lgr) This method adds an object to the queue based on specified priority. |
void |
enqueueNoWait(java.lang.Object obj) |
boolean |
enqueueNoWait(java.lang.Object obj, int priority) This method adds an object to the queue but does not wait if the Q is full. |
int |
getSize() Returns the number of objects in the Q. |
boolean |
isEmpty() This method returns true if the priority Q is empty |
boolean |
isFull() This method returns true if the priority Q has an upper limit set and it is full. |
static void |
main(java.lang.String[] args) A Test Driver |
java.lang.String |
toString() Returns information about the queue in string form |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public WorkQueue()
public WorkQueue(int nMaxPriority)
nMaxPriority
- maximum number of priority types the Q can holdpublic WorkQueue(int nMaxElements, int nMaxPriority)
nMaxElements
- maximum number of elements the queue can containnMaxPriority
- maximum number of priority types the Q can holdMethod Detail |
---|
public void enqueue(java.lang.Object obj, int priority, java.util.logging.Logger lgr) throws QClosedException
obj
- The object to be put in the Qpriority
- the priority category to which the object needs to be addedQClosedException
- if the queue is closed.java.lang.IllegalArgumentException
- if obj is null or the priority is invalidpublic void enqueue(java.lang.Object obj, int priority) throws QClosedException
QClosedException
public void enqueue(java.lang.Object obj) throws QClosedException
QClosedException
public boolean enqueueNoWait(java.lang.Object obj, int priority) throws QClosedException
obj
- The object to be put in the Qpriority
- the priority category to which the object needs to be addedQClosedException
- if the queue is closed.java.lang.IllegalArgumentException
- if obj is null or the priority is invalidpublic void enqueueNoWait(java.lang.Object obj) throws QClosedException
QClosedException
public java.lang.Object dequeue(java.util.logging.Logger lgr) throws QClosedException
QClosedException
- if the queue is empty and closed.public java.lang.Object dequeue() throws QClosedException
QClosedException
public java.lang.Object dequeueNoWait() throws QClosedException
QClosedException
- if the queue is empty and closed.public void close()
public boolean isEmpty()
public boolean isFull()
public int getSize()
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)
|
Oracle Internet Directory API Reference 11g Release 1 (11.1.1) E10664-01 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |