com.bloomberglp.blpapi
Class EventDispatcher

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

public final class EventDispatcher
extends java.lang.Object

Dispatches events from one or more sessions through callbacks.

EventDispatcher objects are optionally specified when Session objects are constructed. A single EventDispatcher can be shared by multiple Session objects. The EventDispatcher provides an event-driven interface, generating callbacks from one or more internal threads for one or more sessions.

Author:
Siva Somu (ssomu)

Nested Class Summary
static class EventDispatcher.StopOption
          Enumerations for controlled shutdown of the EventDispatcher
 
Constructor Summary
EventDispatcher()
          Same as calling EventDispatcher(0)
EventDispatcher(int numThreads)
          Create an EventDispatcher with the specified number of dispatcher threads
EventDispatcher(int numThreads, int maxPendingEvents)
          Deprecated. As of release 3.1.0.0 use SessionOptions.setMaxEventQueueSize(int) for setting the event queue size per session
 
Method Summary
 void dispatcherThread()
          Add a event dispatcher thread to this EventDispatcher
 int numActiveThreads()
          Return the number of active threads dispatching events in this EventDispatcher
 boolean start()
          Start generating callbacks for events from Sessions associated with this EventDispatcher
 void stop()
          Same as calling stop(com.bloomberglp.blpapi.EventDispatcher.StopOption) with EventDispatcher.StopOption.SYNC
 void stop(EventDispatcher.StopOption stopOption)
          Stop generating callbacks for events from sessions
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventDispatcher

public EventDispatcher()
                throws java.io.IOException
Same as calling EventDispatcher(0)

Throws:
java.io.IOException

EventDispatcher

public EventDispatcher(int numThreads)
                throws java.io.IOException
Create an EventDispatcher with the specified number of dispatcher threads

The specified number of threads is >= 1 then a pool of numThreads threads are created to dispatch events. The behavior is undefined if numThreads is zero.

Parameters:
numThreads - the number of dispatcher threads to create
Throws:
java.io.IOException

EventDispatcher

public EventDispatcher(int numThreads,
                       int maxPendingEvents)
                throws java.io.IOException
Deprecated. As of release 3.1.0.0 use SessionOptions.setMaxEventQueueSize(int) for setting the event queue size per session

Parameters:
numThreads -
maxPendingEvents -
Throws:
java.io.IOException
Method Detail

start

public boolean start()
Start generating callbacks for events from Sessions associated with this EventDispatcher

Returns:
true on success

stop

public void stop()
          throws java.lang.InterruptedException
Same as calling stop(com.bloomberglp.blpapi.EventDispatcher.StopOption) with EventDispatcher.StopOption.SYNC

Throws:
java.lang.InterruptedException

stop

public void stop(EventDispatcher.StopOption stopOption)
          throws java.lang.InterruptedException
Stop generating callbacks for events from sessions

Stop generating callbacks for events from sessions associated with this EventDispatcher. If the specified stopOption is EventDispatcher.StopOption.SYNC then this method blocks until all current callbacks which were dispatched through this EventDispatcher have completed. If the stopOption is EventDispatcher.StopOption.ASYNC then this method returns immediately and no further callbacks will be dispatched.

Parameters:
stopOption -
Throws:
java.lang.InterruptedException

dispatcherThread

public void dispatcherThread()
Add a event dispatcher thread to this EventDispatcher

By calling this method applications provide a thread to the EventDispatcher for it to use to dispatch events. This call will not return until the EventDispatcher stops dispatching events. The application can call this method multiple times for the same instance of an EventDispatcher to provide a pool of threads.

This method will return immediately if this EventDispatcher has not been started.


numActiveThreads

public int numActiveThreads()
Return the number of active threads dispatching events in this EventDispatcher



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