org.ourgrid.common.event
Class EventQueue<T extends Event>

java.lang.Object
  extended by org.ourgrid.common.event.EventQueue<T>
Type Parameters:
T -

public class EventQueue<T extends Event>
extends java.lang.Object

This class is desired to queue events in a synchronized way.


Constructor Summary
EventQueue()
          The constructor.
 
Method Summary
 T blockingRemove()
          Removes the first event of the queue.
 void put(T event)
          Adds an event to the end of the queue.
 int size()
          The queue size.
 T unblockingRemove()
          Removes the first event from the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventQueue

public EventQueue()
The constructor.

Method Detail

put

public void put(T event)
Adds an event to the end of the queue.

Parameters:
event - The event to be queued

unblockingRemove

public T unblockingRemove()
Removes the first event from the queue.

Returns:
The first event if exists, otherwise returns null

blockingRemove

public T blockingRemove()
Removes the first event of the queue. If there is no event in the queue, this method blocks until an event is queued.

Returns:
The first event

size

public int size()
The queue size.

Returns:
The size