Class EventDispatcher
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Enumerations for controlled shutdown of the EventDispatcher -
Constructor Summary
ConstructorDescriptionSame as callingEventDispatcher(1)
EventDispatcher
(int numThreads) Create an EventDispatcher with the specified number of dispatcher threadsEventDispatcher
(int numThreads, int maxPendingEvents) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a event dispatcher thread to this EventDispatcherint
Return the number of active threads dispatching events in this EventDispatcherboolean
start()
Start generating callbacks for events from Sessions associated with this EventDispatchervoid
stop()
Same as callingstop(com.bloomberglp.blpapi.EventDispatcher.StopOption)
withEventDispatcher.StopOption.SYNC
void
stop
(EventDispatcher.StopOption stopOption) Stop generating callbacks for events from sessions
-
Constructor Details
-
EventDispatcher
Same as callingEventDispatcher(1)
- Throws:
IOException
-
EventDispatcher
Create an EventDispatcher with the specified number of dispatcher threadsIf
numThreads >= 1
, then a pool of numThreads threads is created to dispatch events. The behavior is undefined ifnumThreads <= 0
.- Parameters:
numThreads
- the number of dispatcher threads to create- Throws:
IOException
-
EventDispatcher
Deprecated.As of release 3.1.0.0 useSessionOptions.setMaxEventQueueSize(int)
for setting the event queue size per session- Parameters:
numThreads
-maxPendingEvents
-- Throws:
IOException
-
-
Method Details
-
start
public boolean start()Start generating callbacks for events from Sessions associated with this EventDispatcher- Returns:
- true on success
-
stop
Same as callingstop(com.bloomberglp.blpapi.EventDispatcher.StopOption)
withEventDispatcher.StopOption.SYNC
- Throws:
InterruptedException
-
stop
Stop generating callbacks for events from sessionsStop 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 isEventDispatcher.StopOption.ASYNC
then this method returns immediately and no further callbacks will be dispatched.- Parameters:
stopOption
-- Throws:
InterruptedException
-
dispatcherThread
public void dispatcherThread()Add a event dispatcher thread to this EventDispatcherBy 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
-
SessionOptions.setMaxEventQueueSize(int)
for setting the event queue size per session