Deleted preserveRemoveSelf because Remove() should always remove a trigger for pooling to work correctly

master
Artem Kolesnykov 2023-02-12 17:26:27 +02:00
parent 663fa737f3
commit 019f8aaf30
1 changed files with 55 additions and 78 deletions

View File

@ -20,8 +20,6 @@ namespace Cysharp.Threading.Tasks
{
ITriggerHandler<T> head; // head.prev is last
ITriggerHandler<T> iteratingHead;
bool preserveRemoveSelf;
ITriggerHandler<T> iteratingNode;
void LogError(Exception ex)
@ -44,6 +42,7 @@ namespace Cysharp.Threading.Tasks
while (h != null)
{
iteratingNode = h;
var next = h.Next;
try
{
@ -55,19 +54,8 @@ namespace Cysharp.Threading.Tasks
Remove(h);
}
if (preserveRemoveSelf)
{
preserveRemoveSelf = false;
iteratingNode = null;
var next = h.Next;
Remove(h);
h = next;
}
else
{
h = h.Next;
}
}
iteratingNode = null;
if (iteratingHead != null)
@ -97,7 +85,6 @@ namespace Cysharp.Threading.Tasks
LogError(ex);
}
preserveRemoveSelf = false;
iteratingNode = null;
var next = h.Next;
Remove(h);
@ -132,7 +119,6 @@ namespace Cysharp.Threading.Tasks
LogError(ex);
}
preserveRemoveSelf = false;
iteratingNode = null;
var next = h.Next;
Remove(h);
@ -167,7 +153,6 @@ namespace Cysharp.Threading.Tasks
LogError(ex);
}
preserveRemoveSelf = false;
iteratingNode = null;
var next = h.Next;
Remove(h);
@ -241,13 +226,6 @@ namespace Cysharp.Threading.Tasks
{
if (handler == null) throw new ArgumentNullException(nameof(handler));
if (iteratingNode != null && iteratingNode == handler)
{
// if remove self, reserve remove self after invoke completed.
preserveRemoveSelf = true;
}
else
{
var prev = handler.Prev;
var next = handler.Next;
@ -307,5 +285,4 @@ namespace Cysharp.Threading.Tasks
handler.Next = null;
}
}
}
}