Depth Check to handle recursion on storage interests.

This commit is contained in:
AlgorithmX2 2014-07-08 11:31:55 -05:00
parent 40e71566ea
commit e322a0a9d3

View file

@ -25,6 +25,7 @@ public class StorageInterestManager {
private final SetMultimap<IAEStack, ItemWatcher> container; private final SetMultimap<IAEStack, ItemWatcher> container;
private LinkedList<SavedTransactions> transactions = null; private LinkedList<SavedTransactions> transactions = null;
private int transDepth=0;
public StorageInterestManager(SetMultimap<IAEStack, ItemWatcher> interests) { public StorageInterestManager(SetMultimap<IAEStack, ItemWatcher> interests) {
container = interests; container = interests;
@ -32,20 +33,28 @@ public class StorageInterestManager {
public void enableTransactions() public void enableTransactions()
{ {
transactions = new LinkedList(); if ( transDepth == 0 )
transactions = new LinkedList();
transDepth++;
} }
public void disableTransactions() public void disableTransactions()
{ {
LinkedList<SavedTransactions> myActions = transactions; transDepth--;
transactions = null;
if ( transDepth == 0 )
for ( SavedTransactions t : myActions )
{ {
if ( t.put ) LinkedList<SavedTransactions> myActions = transactions;
put( t.stack, t.iw ); transactions = null;
else
remove( t.stack, t.iw ); for ( SavedTransactions t : myActions )
{
if ( t.put )
put( t.stack, t.iw );
else
remove( t.stack, t.iw );
}
} }
} }