jclass
Class SimpleQueue

java.lang.Object
  |
  +--jclass.SimpleQueue

public class SimpleQueue
extends java.lang.Object

A class reprezenting a simple static allocated queue of objects which allows also synchronized access. It should make SyncSimpleQueue obsolete.

Written: Radu Sion
Version: 0.19x
Source: SimpleQueue.java

Visit Smart Software 


Field Summary
 long FETCH_TIMEOUT
          This defines the time to wait for a empty queue to receive some object before declaring the queue empty on fetching an object from it.
 long INSERT_TIMEOUT
          This defines the time to wait for a full queue to free up before declaring the queue full on inserting a object into it Should be reasonable small (0-100).
 
Constructor Summary
SimpleQueue(int entr)
           
 
Method Summary
 void clear()
          Clears the queue.
 java.lang.Object fetchNext()
          Gets the next object out of the queue.
 java.lang.Object fetchNext(long timeout)
          Fetches the next object out of queue
 int getMaxSize()
          Gets the maximum size (entries) in the queue
 void Insert(java.lang.Object o)
          Inserts a object in the queue.
 void Insert(java.lang.Object oo, long timeout)
          Inserts a new object into the queue ( no testings are done on the object )
 boolean isEmpty()
          Tests if the queue is empty
 boolean isFull()
nbsp;         Tests if the queue is full.
 int size()
          Returns the current size (entries) of the queue
 boolean waitEmpty(long timeout)
          Waits for empty queue.
 boolean waitFull(long timeout)
          Waits for queue to fill up.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSERT_TIMEOUT

public long INSERT_TIMEOUT
This defines the time to wait for a full queue to free up before declaring the queue full on inserting a object into it Should be reasonable small (0-100). This is used when calling simple Insert(Object). You may change this value.

FETCH_TIMEOUT

public long FETCH_TIMEOUT
This defines the time to wait for a empty queue to receive some object before declaring the queue empty on fetching an object from it. Should be reasonable small (0-100). This is used when calling simple fetchNext(). You may change this value.
Constructor Detail

SimpleQueue

public SimpleQueue(int entr)
Parameters:
entr - The maximum entries in the queue
Method Detail

getMaxSize

public int getMaxSize()
Gets the maximum size (entries) in the queue

isEmpty

public boolean isEmpty()
Tests if the queue is empty

waitEmpty

public boolean waitEmpty(long timeout)
Waits for empty queue. Waits timeout ms before returning false if not empty.
Parameters:
timeout - Negative means wait infinite time.
Returns:
True if empty, False if not empty.

isFull

public boolean isFull()
Tests if the queue is full.

waitFull

public boolean waitFull(long timeout)
Waits for queue to fill up. Waits timeout ms before returning false if not full.
Parameters:
timeout - Negative means wait infinite time.
Returns:
True if queue full, false otherwise.

size

public int size()
Returns the current size (entries) of the queue

fetchNext

public java.lang.Object fetchNext(long timeout)
                           throws EmptyException
Fetches the next object out of queue
Parameters:
timeout - Timeout to wait for Object to enter queue, before throwing EmptyException. Negative means infinity.
Returns:
The next object fetched out of the queue
Throws:
EmptyException - When the queue is empty

Insert

public void Insert(java.lang.Object oo,
                   long timeout)
            throws FullException
Inserts a new object into the queue ( no testings are done on the object )
Parameters:
oo - The object to insert
timeout - Timeout to wait before throwing FullException in the case of full queue.
Throws:
FullException - The queue is full

clear

public void clear()
Clears the queue.

Insert

public void Insert(java.lang.Object o)
            throws FullException
Inserts a object in the queue. See other version of Insert(). This is equivalent to calling Insert(o,0).
Throws:
FullException - If the queue is full.

fetchNext

public java.lang.Object fetchNext()
                           throws EmptyException
Gets the next object out of the queue. See other version of fetchNext(). This is equivalent to calling fetchNext(0).
Throws:
EmptyException - If the queue is empty.