Fix potential missed updates in the level emitter. (#173)

* Fix potential missed updates in the level emitter.

This makes the emitter tickable, but sleeping most of the time so the performance impact should be minimal.
If an update is ignored due to the configured delay, ticking is scheduled to make sure that the update happens if no further network updates happen until the next delay period.

* Attempt #2: Delay the first tick of the level emitter on load

* Revert "NetworkMonitor optimization - do not rebuild cache more than once per tick"

This reverts commit 09b253109c.

* spaces->tabs to match existing code
This commit is contained in:
Raven Szewczyk authored and GitHub committed 2022-09-01 12:58:42 +02:00
1 parent 1a1c9f810d
commit 08d0ef617f
2 files changed
+60 -9

No files matched your search

+1 -4
View File
@@ -56,7 +56,6 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
private boolean sendEvent = false;
private boolean hasChanged = false;
private boolean ticked = true;
@Nonnegative
private int localDepthSemaphore = 0;
@@ -134,10 +133,9 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
@Override
public IItemList<T> getStorageList()
{
if( hasChanged && ticked )
if( this.hasChanged )
{
this.hasChanged = false;
ticked = false;
this.cachedList.resetStatus();
return this.getAvailableItems( this.cachedList );
}
@@ -331,7 +329,6 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
void onTick()
{
ticked = true;
if( this.sendEvent )
{
this.sendEvent = false;