org.opennms.netmgt.linkd.scheduler
Class Scheduler.PeekableFifoQueue<T>

java.lang.Object
  extended by org.opennms.core.queue.FifoQueueImpl<T>
      extended by org.opennms.netmgt.linkd.scheduler.Scheduler.PeekableFifoQueue<T>
All Implemented Interfaces:
FifoQueue<T>
Enclosing class:
Scheduler

public static final class Scheduler.PeekableFifoQueue<T>
extends FifoQueueImpl<T>

This queue extends the standard FIFO queue instance so that it is possible to peek at an instance without removing it from the queue.


Method Summary
 boolean isEmpty()
          Used to test if the current queue has no stored elements.
 T peek()
          This method allows the caller to peek at the next object that would be returned on a remove call.
 T remove()
          Removes the next element from the queue and returns it to the caller.
 T remove(long timeout)
          Removes the next element from the queue and returns it to the caller.
 
Methods inherited from class org.opennms.core.queue.FifoQueueImpl
add, add, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

peek

public T peek()
       throws InterruptedException,
              FifoQueueException
This method allows the caller to peek at the next object that would be returned on a remove call. If the queue is currently empty then the caller is blocked until an object is put into the queue.

Returns:
The object that would be returned on the next call to remove.
Throws:
InterruptedException - Thrown if the thread is interrupted.
FifoQueueException - Thrown if an error occurs removing an item from the queue.

remove

public T remove()
         throws InterruptedException,
                FifoQueueException
Removes the next element from the queue and returns it to the caller. If there is no objects available then the caller is blocked until an item is available.

Specified by:
remove in interface FifoQueue<T>
Overrides:
remove in class FifoQueueImpl<T>
Returns:
The next element in the queue.
Throws:
InterruptedException - Thrown if the thread is interrupted.
FifoQueueException - Thrown if an error occurs removing an item from the queue.

remove

public T remove(long timeout)
         throws InterruptedException,
                FifoQueueException
Removes the next element from the queue and returns it to the caller. If there is no objects available then the caller is blocked until an item is available. If an object is not available within the time frame specified by timeout.

Specified by:
remove in interface FifoQueue<T>
Overrides:
remove in class FifoQueueImpl<T>
Parameters:
timeout - The maximum time to wait.
Returns:
The next element in the queue.
Throws:
InterruptedException - Thrown if the thread is interrupted.
FifoQueueException - Thrown if an error occurs removing an item from the queue.

isEmpty

public boolean isEmpty()
Used to test if the current queue has no stored elements.

Specified by:
isEmpty in interface FifoQueue<T>
Overrides:
isEmpty in class FifoQueueImpl<T>
Returns:
True if the queue is empty.


Copyright © 2011. All Rights Reserved.