Skip to content

Commit

Permalink
Fix error in SynchronizationStrategy.PlayerLoop
Browse files Browse the repository at this point in the history
  • Loading branch information
hadashiA committed May 24, 2024
1 parent 58cad6d commit e680476
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
16 changes: 6 additions & 10 deletions Assets/Unio/Internal/FileReadPromise.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ public void WaitForComplete()
}
}

if (!MoveNext())
{
throw new InvalidOperationException($"ReadHandle is completed but ReadHandle is not completed. {filePath} {status}");
}

if (status != ReadStatus.Complete)
{
throw new UnioIOException(filePath, status);
Expand All @@ -131,13 +126,13 @@ public bool MoveNext()
readHandle.Cancel();
}
completionSource?.TrySetCanceled();
return false;
}
finally
{
ReleaseHandle();
ReleaseBuffer();
}
return false;
}

switch (readHandle.Status)
Expand All @@ -150,27 +145,28 @@ public bool MoveNext()
var result = GetResult();
completionSource.TrySetResult(result);
}
break;
return false;
}
case ReadStatus.Failed:
case ReadStatus.Truncated:
{
ReleaseHandle();
ReleaseBuffer();
completionSource?.TrySetException(new UnioIOException(filePath, readHandle.Status));
break;
return false;
}
case ReadStatus.Canceled:
{
ReleaseHandle();
ReleaseBuffer();
completionSource?.TrySetCanceled();
break;
return false;
}
case ReadStatus.InProgress:
return true;
default:
throw new ArgumentOutOfRangeException();
}
return true;
}

void ReleaseHandle()
Expand Down
3 changes: 2 additions & 1 deletion Assets/Unio/Internal/PlayerLoopHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ static void InsertSubsystem(ref PlayerLoopSystem parentSystem, Type beforeType,
if (source[i].type == beforeType)
{
insertIndex = i;
break;
}
}

Expand All @@ -103,7 +104,7 @@ static void InsertSubsystem(ref PlayerLoopSystem parentSystem, Type beforeType,
throw new ArgumentException($"{beforeType.FullName} not in system {parentSystem} {parentSystem.type.FullName}");
}

var dest = new PlayerLoopSystem[source.Length + 2];
var dest = new PlayerLoopSystem[source.Length + 1];
for (var i = 0; i < dest.Length; i++)
{
if (i == insertIndex)
Expand Down
1 change: 0 additions & 1 deletion Assets/Unio/NativeFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public static BytesTaskType ReadAllBytesAsync(string filePath, SynchronizationSt
break;
case SynchronizationStrategy.PlayerLoop:
{
PlayerLoopHelper.EnsureInitialized();
PlayerLoopHelper.Dispatch(PlayerLoopTiming.Update, promise);
break;
}
Expand Down

0 comments on commit e680476

Please sign in to comment.