Revamped onChange Events to post lists of items making bulk operations much less cpu intensive.

This commit is contained in:
AlgorithmX2
2014-09-10 23:12:34 -05:00
parent 3f91868d5e
commit 5b79ad0b8c
12 changed files with 83 additions and 88 deletions
+26 -19
View File
@@ -48,8 +48,7 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
final static public LinkedList depth = new LinkedList();
@Override
protected void postChange(T diff, BaseActionSource src)
protected void postChange(boolean Add, Iterable<T> changes, BaseActionSource src)
{
if ( depth.contains( this ) )
return;
@@ -57,28 +56,36 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
depth.push( this );
sendEvent = true;
super.postChange( diff, src );
postChangeToListeners( changes, src );
if ( myGridCache.interestManager.containsKey( diff ) )
IItemList<T> myStorageList = getStorageList();
for (T changedItem : changes)
{
Set<ItemWatcher> list = myGridCache.interestManager.get( diff );
if ( !list.isEmpty() )
{
IItemList<T> myStorageList = getStorageList();
T diffrence = changedItem;
IAEStack fullStack = myStorageList.findPrecise( diff );
if ( fullStack == null )
if ( !Add && changedItem != null )
(diffrence = changedItem.copy()).setStackSize( -changedItem.getStackSize() );
if ( myGridCache.interestManager.containsKey( changedItem ) )
{
Set<ItemWatcher> list = myGridCache.interestManager.get( changedItem );
if ( !list.isEmpty() )
{
fullStack = diff.copy();
fullStack.setStackSize( 0 );
IAEStack fullStack = myStorageList.findPrecise( changedItem );
if ( fullStack == null )
{
fullStack = changedItem.copy();
fullStack.setStackSize( 0 );
}
myGridCache.interestManager.enableTransactions();
for (ItemWatcher iw : list)
iw.getHost().onStackChange( myStorageList, fullStack, diffrence, src, getChannel() );
myGridCache.interestManager.disableTransactions();
}
myGridCache.interestManager.enableTransactions();
for (ItemWatcher iw : list)
iw.getHost().onStackChange( myStorageList, fullStack, diff, src, getChannel() );
myGridCache.interestManager.disableTransactions();
}
}