|
|
@@ -4,29 +4,24 @@ namespace Avalonia.Rendering.Composition.Server
|
|
|
{
|
|
|
private readonly object _lock = new object();
|
|
|
public int ReadIndex { get; private set; } = 0;
|
|
|
- public int WriteIndex { get; private set; } = -1;
|
|
|
+ public int WriteIndex { get; private set; } = 1;
|
|
|
+ public int WrittenIndex { get; private set; } = 0;
|
|
|
public ulong ReadRevision { get; private set; }
|
|
|
- public ulong WriteRevision { get; private set; }
|
|
|
- private ulong[] _revisions = new ulong[3];
|
|
|
-
|
|
|
-
|
|
|
+ public ulong LastWrittenRevision { get; private set; }
|
|
|
+
|
|
|
public void NextRead()
|
|
|
{
|
|
|
lock (_lock)
|
|
|
{
|
|
|
- for (var c = 0; c < 3; c++)
|
|
|
+ if (ReadRevision < LastWrittenRevision)
|
|
|
{
|
|
|
- if (c != WriteIndex && c != ReadIndex && _revisions[c] > ReadRevision)
|
|
|
- {
|
|
|
- ReadIndex = c;
|
|
|
- ReadRevision = _revisions[c];
|
|
|
- return;
|
|
|
- }
|
|
|
+ ReadIndex = WrittenIndex;
|
|
|
+ ReadRevision = LastWrittenRevision;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void NextWrite(ulong revision)
|
|
|
+ public void CompleteWrite(ulong writtenRevision)
|
|
|
{
|
|
|
lock (_lock)
|
|
|
{
|
|
|
@@ -34,9 +29,9 @@ namespace Avalonia.Rendering.Composition.Server
|
|
|
{
|
|
|
if (c != WriteIndex && c != ReadIndex)
|
|
|
{
|
|
|
+ WrittenIndex = WriteIndex;
|
|
|
+ LastWrittenRevision = writtenRevision;
|
|
|
WriteIndex = c;
|
|
|
- WriteRevision = revision;
|
|
|
- _revisions[c] = revision;
|
|
|
return;
|
|
|
}
|
|
|
}
|