public final class EventDispatcher extends Object
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
EventDispatcher.StopOption
Enumerations for controlled shutdown of the EventDispatcher
|
| Constructor and Description |
|---|
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 |
| Modifier and Type | Method and Description |
|---|---|
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
|
public EventDispatcher()
throws IOException
EventDispatcher(0)IOExceptionpublic EventDispatcher(int numThreads)
throws IOException
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.
numThreads - the number of dispatcher threads to createIOExceptionpublic EventDispatcher(int numThreads,
int maxPendingEvents)
throws IOException
SessionOptions.setMaxEventQueueSize(int) for setting the
event queue size per sessionnumThreads - maxPendingEvents - IOExceptionpublic boolean start()
public void stop()
throws InterruptedException
stop(com.bloomberglp.blpapi.EventDispatcher.StopOption) with
EventDispatcher.StopOption.SYNCInterruptedExceptionpublic void stop(EventDispatcher.StopOption stopOption) throws InterruptedException
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.
stopOption - InterruptedExceptionpublic void dispatcherThread()
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.
public int numActiveThreads()
Copyright © 2017 Bloomberg L.P.. All rights reserved.