com.bloomberglp.blpapi
Class EventQueue

java.lang.Object
  extended by com.bloomberglp.blpapi.EventQueue

public class EventQueue
extends java.lang.Object

The EventQueue class allows an application to block and receive Events for requests in a synchronous manner.

An Request can be associated with an EventQueue by passing a valid instance of the EventQueue class to the sendRequest and sendAuthorizationRequest methods. All responses to the Request are now delivered to this EventQueue allowing the application to block for Responses for the Request. Note that a single EventQueue can be used for receiving Response Events for many requests.

Author:
ssomu

Constructor Summary
EventQueue()
          Construct an empty event queue.
 
Method Summary
 Event nextEvent()
          Retrieves the next event available for processing on this EventQueue
 Event nextEvent(long timeoutMillis)
          Retrieves the next event available for processing on this EventQueue
 void purge()
          Purge all events from this Event Queue and cancel all Requests that this Event Queue is associated with
 Event tryNextEvent()
          Tries to retrieve the next event available for processing on this EventQueue
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventQueue

public EventQueue()
Construct an empty event queue.

Method Detail

nextEvent

public Event nextEvent()
                throws java.lang.InterruptedException
Retrieves the next event available for processing on this EventQueue

This method is the same as calling nextEvent(0)

Returns:
next event available on this session
Throws:
java.lang.InterruptedException - if another thread has interrupted the current thread

nextEvent

public Event nextEvent(long timeoutMillis)
                throws java.lang.InterruptedException
Retrieves the next event available for processing on this EventQueue

retrieve the next event available for processing on this EventQueue. If no event is available immediately wait for timeoutMillis milliseconds for an event to arrive. If no event is received before the timeout expires return a Event.EventType.TIMEOUT event. If the timeout specified is 0 then wait for an infinite amount of time for an event to be received.

Parameters:
timeoutMillis - timeout in milliseconds to wait for an event to be available
Returns:
next event available before timeout or Event.EventType.TIMEOUT event if timeout occurs
Throws:
java.lang.InterruptedException - if another thread has interrupted the current thread

tryNextEvent

public Event tryNextEvent()
Tries to retrieve the next event available for processing on this EventQueue

This method never blocks.

Returns:
next event available on this session if available or null if no event is available immediately

purge

public void purge()
Purge all events from this Event Queue and cancel all Requests that this Event Queue is associated with

Purges any Event objects in this EventQueue which have not been processed and cancel any pending requests linked to this EventQueue. The EventQueue can subsequently be re-used for a subsequent request.



Copyright © 2015 Bloomberg L.P.. All Rights Reserved.