Skip to content

Commit 42f5d34

Browse files
committed
add notready error case
1 parent 3af7acc commit 42f5d34

File tree

6 files changed

+11
-9
lines changed

6 files changed

+11
-9
lines changed

benchmarks/Backdash.Benchmarks/Cases/StructWriteBenchmark.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ public void ReadWrite()
4343
public void AsBytes()
4444
{
4545
var buffer = GetBuffer();
46-
Mem.AsBytes(in data).CopyTo(buffer);
46+
Mem.AsBytes(ref data).CopyTo(buffer);
4747

4848
StructData copy = default;
49-
buffer.CopyTo(Mem.AsBytes(in copy));
49+
buffer.CopyTo(Mem.AsBytes(ref copy));
5050

5151
Debug.Assert(data == copy);
5252
}

src/Backdash/Core/Mem.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ static class Mem
1515
public static ReadOnlySpan<T> AsSpan<T>(ref readonly T data) where T : unmanaged => new(in data);
1616

1717
[MethodImpl(MethodImplOptions.AggressiveInlining)]
18-
public static Span<byte> AsBytes<T>(scoped ref readonly T data) where T : unmanaged =>
19-
MemoryMarshal.AsBytes(new Span<T>(ref Unsafe.AsRef(in data)));
18+
public static Span<byte> AsBytes<T>(ref T data) where T : unmanaged => MemoryMarshal.AsBytes(new Span<T>(ref data));
2019

2120
public static bool EqualBytes(ReadOnlySpan<byte> left, ReadOnlySpan<byte> right, bool truncate = false)
2221
{

src/Backdash/Network/Protocol/Comm/ProtocolInbox.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void OnPeerMessage(ref readonly ProtocolMessage message, in SocketAddress
5050
}
5151

5252
var seqNum = message.Header.SequenceNumber;
53-
if (message.Header.Type is not MessageType.SyncRequest and not MessageType.SyncReply)
53+
if (message.Header.Type is not (MessageType.SyncRequest or MessageType.SyncReply))
5454
{
5555
if (state.CurrentStatus is not ProtocolStatus.Running)
5656
{
@@ -245,7 +245,7 @@ bool OnSyncReply(ref readonly ProtocolMessage msg, ref ProtocolMessage replyMsg)
245245
if (options.NumberOfSyncRoundTrips >= state.Sync.RemainingRoundTrips)
246246
state.Sync.TotalRoundTripsPing = TimeSpan.Zero;
247247
state.Sync.TotalRoundTripsPing += elapsed;
248-
if (--state.Sync.RemainingRoundTrips == 0)
248+
if (--state.Sync.RemainingRoundTrips is 0)
249249
{
250250
var ping = state.Sync.TotalRoundTripsPing / options.NumberOfSyncRoundTrips;
251251
logger.Write(LogLevel.Information,

src/Backdash/ResultCode.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,7 @@ public enum ResultCode : short
5151

5252
/// <summary>The current session type not support the requested operation.</summary>
5353
NotSupported,
54+
55+
/// <summary>The value is not ready to be ready.</summary>
56+
NotReady,
5457
}

src/Backdash/Session/Backends/SpectatorSession.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public ResultCode SynchronizeInputs()
309309
if (input.Frame.Number < CurrentFrame.Number)
310310
{
311311
// Haven't received the input from the host yet. Wait
312-
return ResultCode.PredictionThreshold;
312+
return ResultCode.NotReady;
313313
}
314314

315315
if (input.Frame.Number > CurrentFrame.Number)

tests/Backdash.Tests/Backdash.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
<PackageReference Include="FakeItEasy.AutoFakeIt" Version="2.0.0"/>
1515
<PackageReference Include="FluentAssertions" Version="[7.2.0]"/>
1616
<PackageReference Include="FsCheck.Xunit" Version="3.3.2" />
17-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
1818
<PackageReference Include="ObjectLayoutInspector" Version="0.1.4" />
1919
<PackageReference Include="xunit" Version="2.9.3" />
2020
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
2121
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2222
<PrivateAssets>all</PrivateAssets>
2323
</PackageReference>
24-
<PackageReference Include="coverlet.collector" Version="6.0.4">
24+
<PackageReference Include="coverlet.collector" Version="8.0.0">
2525
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2626
<PrivateAssets>all</PrivateAssets>
2727
</PackageReference>

0 commit comments

Comments
 (0)