|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.osgi.framework.eventmgr.ListenerQueue
public class ListenerQueue
The ListenerQueue is used to snapshot the set of listeners at the time the event is fired. The snapshot list is then used to dispatch events to those listeners. A ListenerQueue object is associated with a specific EventManager object. ListenerQueue objects constructed with the same EventManager object will get in-order delivery of events using asynchronous delivery. No delivery order is guaranteed for synchronous delivery to avoid any potential deadly embraces.
ListenerQueue objects are created as necesssary to build a set of listeners that should receive a specific event or events. Once the set is created, the event can then be synchronously or asynchronously delivered to the set of listeners. After the event has been dispatched for delivery, the ListenerQueue object should be discarded as it is likely the list of listeners is stale. A new ListenerQueue object should be created when it is time to deliver another event. The memory cost of a ListenerQueue object is low since the ListenerQueue object shares the array of listeners with the EventListeners object which are queued. EventListeners uses copy-on-write semantics for managing the array and will copy the array before changing it once the array has been shared with a ListenerQueue. This minimizes object creation while guaranteeing the snapshot list is never modified once created.
Field Summary | |
---|---|
protected EventManager |
manager
EventManager with which this queue is associated. |
Constructor Summary | |
---|---|
ListenerQueue(EventManager manager)
ListenerQueue constructor. |
Method Summary | |
---|---|
void |
dispatchEventAsynchronous(int eventAction,
java.lang.Object eventObject)
Asynchronously dispatch an event to the snapshot list. |
void |
dispatchEventSynchronous(int eventAction,
java.lang.Object eventObject)
Synchronously dispatch an event to the snapshot list. |
void |
queueListeners(EventListeners listeners,
EventDispatcher dispatcher)
Add a listener list to the snapshot list. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final EventManager manager
Constructor Detail |
---|
public ListenerQueue(EventManager manager)
manager
- The EventManager this queue is associated with.
java.lang.IllegalArgumentException
- If manager is null.Method Detail |
---|
public void queueListeners(EventListeners listeners, EventDispatcher dispatcher)
listeners
- An EventListeners object to add to the queue. The current listeners
in the EventListeners object will be called when an event is dispatched.dispatcher
- An EventDispatcher object to use when dispatching an event
to the listeners on the specified EventListeners.
java.lang.IllegalStateException
- If called after one of the dispatch methods has been called.public void dispatchEventAsynchronous(int eventAction, java.lang.Object eventObject)
eventAction
- This value is passed to the EventDispatcher.eventObject
- This object is passed to the EventDispatcher.public void dispatchEventSynchronous(int eventAction, java.lang.Object eventObject)
eventAction
- This value is passed to the EventDispatcher.eventObject
- This object is passed to the EventDispatcher.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |