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> head; // head.prev is last
ITriggerHandler<T> iteratingHead; ITriggerHandler<T> iteratingHead;
bool preserveRemoveSelf;
ITriggerHandler<T> iteratingNode; ITriggerHandler<T> iteratingNode;
void LogError(Exception ex) void LogError(Exception ex)
@ -44,6 +42,7 @@ namespace Cysharp.Threading.Tasks
while (h != null) while (h != null)
{ {
iteratingNode = h; iteratingNode = h;
var next = h.Next;
try try
{ {
@ -55,19 +54,8 @@ namespace Cysharp.Threading.Tasks
Remove(h); Remove(h);
} }
if (preserveRemoveSelf)
{
preserveRemoveSelf = false;
iteratingNode = null;
var next = h.Next;
Remove(h);
h = next; h = next;
} }
else
{
h = h.Next;
}
}
iteratingNode = null; iteratingNode = null;
if (iteratingHead != null) if (iteratingHead != null)
@ -97,7 +85,6 @@ namespace Cysharp.Threading.Tasks
LogError(ex); LogError(ex);
} }
preserveRemoveSelf = false;
iteratingNode = null; iteratingNode = null;
var next = h.Next; var next = h.Next;
Remove(h); Remove(h);
@ -132,7 +119,6 @@ namespace Cysharp.Threading.Tasks
LogError(ex); LogError(ex);
} }
preserveRemoveSelf = false;
iteratingNode = null; iteratingNode = null;
var next = h.Next; var next = h.Next;
Remove(h); Remove(h);
@ -167,7 +153,6 @@ namespace Cysharp.Threading.Tasks
LogError(ex); LogError(ex);
} }
preserveRemoveSelf = false;
iteratingNode = null; iteratingNode = null;
var next = h.Next; var next = h.Next;
Remove(h); Remove(h);
@ -241,13 +226,6 @@ namespace Cysharp.Threading.Tasks
{ {
if (handler == null) throw new ArgumentNullException(nameof(handler)); 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 prev = handler.Prev;
var next = handler.Next; var next = handler.Next;
@ -308,4 +286,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
} }
}