avoid relaying changes if theres no one listening to the passthrough
This commit is contained in:
@@ -52,4 +52,9 @@ public interface IMEMonitorHandlerReceiver<T extends IAEStack<T>>
|
|||||||
* called when the list updates its contents, this is mostly for handling power events.
|
* called when the list updates its contents, this is mostly for handling power events.
|
||||||
*/
|
*/
|
||||||
void onListUpdate();
|
void onListUpdate();
|
||||||
|
|
||||||
|
default boolean hasListeners()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -262,7 +262,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
{
|
{
|
||||||
final Entry<IMEMonitorHandlerReceiver<T>, Object> o = i.next();
|
final Entry<IMEMonitorHandlerReceiver<T>, Object> o = i.next();
|
||||||
final IMEMonitorHandlerReceiver<T> receiver = o.getKey();
|
final IMEMonitorHandlerReceiver<T> receiver = o.getKey();
|
||||||
if( receiver.isValid( o.getValue() ) )
|
if( receiver.isValid( o.getValue() ) && receiver.hasListeners() )
|
||||||
{
|
{
|
||||||
receiver.postChange( this, diff, src );
|
receiver.postChange( this, diff, src );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,6 +90,13 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
|
|||||||
@Override
|
@Override
|
||||||
public void addListener( final IMEMonitorHandlerReceiver<T> l, final Object verificationToken )
|
public void addListener( final IMEMonitorHandlerReceiver<T> l, final Object verificationToken )
|
||||||
{
|
{
|
||||||
|
if( this.listeners.size() == 0 )
|
||||||
|
{
|
||||||
|
if( this.monitor != null )
|
||||||
|
{
|
||||||
|
this.monitor.addListener( this, this.monitor );
|
||||||
|
}
|
||||||
|
}
|
||||||
this.listeners.put( l, verificationToken );
|
this.listeners.put( l, verificationToken );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +124,12 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
|
|||||||
return verificationToken == this.monitor;
|
return verificationToken == this.monitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasListeners()
|
||||||
|
{
|
||||||
|
return this.listeners.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postChange( final IBaseMonitor<T> monitor, final Iterable<T> change, final IActionSource source )
|
public void postChange( final IBaseMonitor<T> monitor, final Iterable<T> change, final IActionSource source )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user