Service Activator Toolkit
Version 1.1.0 (20081206)

org.eclipse.soda.sat.core.framework.interfaces
Interface IQueue


public interface IQueue

The IQueue interface defines a FIFO container. An instance of IQueue can be created using the FactoryUtility singleton.

 FactoryUtility utility = FactoryUtility.getInstance();
 IQueue queue = utility.createQueue(10);
 
Objects are added to the queue using the add(Object) method.
 queue.add("Monday");
 queue.add("Tuesday");
 queue.add("Wednesday");
 
Objects are removed from the queue using the remove() method that blocks while the queue is empty.
 try {
   while (true) {
     String day = (String) queue.remove();
     processDay(day);
   }
 } catch (InterruptedException exception);
   // OK
 }
 
Object can also be removed from the queue using the remove(long) method that blocks for at least the specified millisecond timeout while the queue is empty.
 try {
   while (true) {
     String day = (String) queue.remove(1000);  // Block for at least 1 second.
     if (day == null)
       break;  // The queue is empty.
     processDay(day);
   }
 } catch (InterruptedException exception);
   // OK
 }
 

See Also:
FactoryUtility

Method Summary
 void add(Object item)
          Add the specified item to the queue.
 boolean contains(Object item)
          Check to see if the specified item exists in the queue.
 boolean isEmpty()
          Check to see if the queue is empty.
 Object remove()
          Remove and return the next item in the queue.
 Object remove(long timeout)
          Remove and return the next item in the queue.
 int size()
          Query the size of the queue.
 

Method Detail

add

void add(Object item)
Add the specified item to the queue.

Parameters:
item - The item to add to the queue.

contains

boolean contains(Object item)
Check to see if the specified item exists in the queue.

Parameters:
item - The item to check for.
Returns:
True if the item exists, otherwise false.

isEmpty

boolean isEmpty()
Check to see if the queue is empty.

Returns:
True if the queue is empty, otherwise false.

remove

Object remove()
              throws InterruptedException
Remove and return the next item in the queue. This method blocks the calling thread indefinitely while the queue is empty.

Returns:
The item removed from the queue.
Throws:
InterruptedException

remove

Object remove(long timeout)
              throws InterruptedException
Remove and return the next item in the queue. This method blocks the calling thread for at least the specified timeout while the queue is empty.

Parameters:
timeout - The number of milliseconds to wait for the queue to no longer be empty.
Returns:
The item removed from the queue.
Throws:
InterruptedException

size

int size()
Query the size of the queue.

Returns:
The size of the queue.

Service Activator Toolkit
Version 1.1.0 (20081206)