dotnet - add locking since the simulator seems to run a lot in parallel

change the port to match what the simulator uses by default

add serilog as part of debugging
This commit is contained in:
2026-08-06 15:54:07 -05:00
parent 9a1664bdbb
commit 459b90dcd7
6 changed files with 117 additions and 29 deletions
+8 -4
View File
@@ -5,16 +5,20 @@ namespace SafelyYou;
public sealed class UploadTimes
{
private readonly Lock _lock = new();
private readonly ConcurrentDictionary<DeviceId, (BigInteger TotalUploadTime, int UploadCounts)> _uploadHistories = new();
public void Add(DeviceId deviceId, BigInteger uploadTimeNanos)
{
if (!_uploadHistories.TryGetValue(deviceId, out var history))
lock (_lock)
{
history = (BigInteger.Zero, 0);
}
if (!_uploadHistories.TryGetValue(deviceId, out var history))
{
history = (BigInteger.Zero, 0);
}
_uploadHistories[deviceId] = (history.TotalUploadTime + uploadTimeNanos, history.UploadCounts + 1);
_uploadHistories[deviceId] = (history.TotalUploadTime + uploadTimeNanos, history.UploadCounts + 1);
}
}
public BigInteger AverageUploadTimeNanoseconds(DeviceId deviceId)