Notify client observers directly if we're already on the RunQueue thread.
This avoids a needless wait in the run queue for most notifications. Only notifications that result directly from something one of the communicator threads did will need to do a loop de loop. This should close the hole where ClientObserver could be told that the ClientObject was available *after* some events have come in on the ClientObject (which they then miss). Now when the subscription response comes in for the ClientObject, observers are notified immediately, and will be wired up and ready for any messages that are themselves already in the queue ready to be dispatched.
This commit is contained in:
@@ -879,9 +879,13 @@ public class Client
|
||||
|
||||
protected void notifyObservers (final ObserverOps.Session op)
|
||||
{
|
||||
if (_runQueue == null) {
|
||||
// if we have no run queue, or we're already on the run queue's thread; dispatch this
|
||||
// operation immediately on the current thread
|
||||
if (_runQueue == null || _runQueue.isDispatchThread()) {
|
||||
_observers.apply(op);
|
||||
} else {
|
||||
}
|
||||
// otherwise queue this notification up to run on the run queue thread
|
||||
else {
|
||||
_runQueue.postRunnable(new Runnable() {
|
||||
public void run () {
|
||||
_observers.apply(op);
|
||||
|
||||
Reference in New Issue
Block a user