L4 theoretical work

This commit is contained in:
Youmu Liu
2026-10-16 18:19:34 +08:00
parent 91cf6a43cd
commit d1efb15e3f
2 changed files with 14 additions and 7 deletions
@@ -45,8 +45,7 @@ namespace Nitload.Common.HighPerformance.Memory
if (ReferenceEquals(predictor, _ring[idx]))
{
int end = _predict;
for (int move = i; move < end - 1; move++)
{
for (int move = i; move < end - 1; move++) {
_ring[(byte)move] = _ring[(byte)(move + 1)];
}
_ring[(byte)(end - 1)] = default!;
@@ -58,7 +57,7 @@ namespace Nitload.Common.HighPerformance.Memory
}
finally
{
Interlocked.Exchange(ref _queue_sync, 0);
_ = Interlocked.Exchange(ref _queue_sync, 0);
}
}
@@ -77,9 +76,18 @@ namespace Nitload.Common.HighPerformance.Memory
WaitForSpare();
_consume++;
byte idx = (byte)_consume;
_ring[idx] = predictor;
try
{
unchecked
{
byte idx = (byte)_consume;
_ring[idx] = predictor;
}
}
finally
{
_ = Interlocked.Exchange(ref _queue_sync, 0);
}
}
private void WaitForSpare()
@@ -33,5 +33,4 @@ namespace Nitload.Common.HighPerformance.Memory
}
internal class PredictorMonitor { }
}