Attempted to fix FPS drop on Grid sorting, fixes #1674
This commit is contained in:
		@@ -11,6 +11,7 @@
 | 
				
			|||||||
- Fixed Disk Manipulator being stuck on unemptiable, non-empty disks (ineternet)
 | 
					- Fixed Disk Manipulator being stuck on unemptiable, non-empty disks (ineternet)
 | 
				
			||||||
- Fixed orientations of the Portable Grid (TeamSpen210)
 | 
					- Fixed orientations of the Portable Grid (TeamSpen210)
 | 
				
			||||||
- Fixed crafting event in Crafting Grid being fired twice (raoulvdberge)
 | 
					- Fixed crafting event in Crafting Grid being fired twice (raoulvdberge)
 | 
				
			||||||
 | 
					- Attempted to fix FPS drop on Grid sorting (raoulvdberge)
 | 
				
			||||||
- Disk Manipulator in fluid mode will now extract a bucket at a time instead of 1 mB (or 64 buckets at a time with a Stack Upgrade instead of 64 mB) (raoulvdberge)
 | 
					- Disk Manipulator in fluid mode will now extract a bucket at a time instead of 1 mB (or 64 buckets at a time with a Stack Upgrade instead of 64 mB) (raoulvdberge)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### 1.5.31
 | 
					### 1.5.31
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -62,8 +62,8 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
 | 
				
			|||||||
    public static List<IGridStack> STACKS = new ArrayList<>();
 | 
					    public static List<IGridStack> STACKS = new ArrayList<>();
 | 
				
			||||||
    public static boolean CAN_CRAFT;
 | 
					    public static boolean CAN_CRAFT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static boolean SCHEDULE_SORT = false;
 | 
					    private static final Sorter SORTER = new Sorter();
 | 
				
			||||||
    private Queue<Sorter> sortingQueue = new ArrayDeque<>();
 | 
					    private static boolean SCHEDULE_SORT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private boolean wasConnected;
 | 
					    private boolean wasConnected;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -210,16 +210,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
 | 
				
			|||||||
        if (SCHEDULE_SORT) {
 | 
					        if (SCHEDULE_SORT) {
 | 
				
			||||||
            SCHEDULE_SORT = false;
 | 
					            SCHEDULE_SORT = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sortingQueue.add(new Sorter(this));
 | 
					            SORTER.startIfPossible(this);
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Sorter sorter = sortingQueue.peek();
 | 
					 | 
				
			||||||
        if (sorter != null) {
 | 
					 | 
				
			||||||
            if (!sorter.isStarted()) {
 | 
					 | 
				
			||||||
                sorter.start();
 | 
					 | 
				
			||||||
            } else if (sorter.isDone()) {
 | 
					 | 
				
			||||||
                sortingQueue.poll();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,15 +18,10 @@ public class Sorter implements Runnable {
 | 
				
			|||||||
    private static final GridSorting SORTING_INVENTORYTWEAKS = new GridSortingInventoryTweaks();
 | 
					    private static final GridSorting SORTING_INVENTORYTWEAKS = new GridSortingInventoryTweaks();
 | 
				
			||||||
    private static final GridSorting SORTING_LAST_MODIFIED = new GridSortingLastModified();
 | 
					    private static final GridSorting SORTING_LAST_MODIFIED = new GridSortingLastModified();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private boolean done;
 | 
					    private boolean busy;
 | 
				
			||||||
    private boolean started;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private GuiGrid gui;
 | 
					    private GuiGrid gui;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public Sorter(GuiGrid gui) {
 | 
					 | 
				
			||||||
        this.gui = gui;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void run() {
 | 
					    public void run() {
 | 
				
			||||||
        IGrid grid = gui.getGrid();
 | 
					        IGrid grid = gui.getGrid();
 | 
				
			||||||
@@ -90,20 +85,15 @@ public class Sorter implements Runnable {
 | 
				
			|||||||
            gui.getTabPageRight().visible = grid.getTotalTabPages() > 0;
 | 
					            gui.getTabPageRight().visible = grid.getTotalTabPages() > 0;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.done = true;
 | 
					        this.busy = false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void start() {
 | 
					    public void startIfPossible(GuiGrid gui) {
 | 
				
			||||||
        this.started = true;
 | 
					        if (!busy) {
 | 
				
			||||||
 | 
					            this.busy = true;
 | 
				
			||||||
 | 
					            this.gui = gui;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        new Thread(this, "RS grid sorting").start();
 | 
					            new Thread(this, "RS grid sorting").start();
 | 
				
			||||||
    }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    public boolean isStarted() {
 | 
					 | 
				
			||||||
        return started;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public boolean isDone() {
 | 
					 | 
				
			||||||
        return done;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user