mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-25 11:29:37 +02:00
* simplify TThread.RemoveQueuedEvent - decide what to delete and not what to leave (better corresponds with the docs)
git-svn-id: trunk@47011 -
This commit is contained in:
parent
69fcacc948
commit
192bbc07f5
@ -602,42 +602,35 @@ begin
|
|||||||
lastentry := Nil;
|
lastentry := Nil;
|
||||||
entry := ThreadQueueHead;
|
entry := ThreadQueueHead;
|
||||||
while Assigned(entry) do begin
|
while Assigned(entry) do begin
|
||||||
{ first check for the thread }
|
if
|
||||||
if Assigned(aThread) and (entry^.Thread <> aThread) and (entry^.ThreadID <> aThread.ThreadID) then begin
|
{ only entries not added by Synchronize }
|
||||||
lastentry := entry;
|
not Assigned(entry^.SyncEvent)
|
||||||
entry := entry^.Next;
|
{ check for the thread }
|
||||||
Continue;
|
and (not Assigned(aThread) or (entry^.Thread = aThread) or (entry^.ThreadID = aThread.ThreadID))
|
||||||
end;
|
{ check for the method }
|
||||||
{ then check for the method }
|
and (not Assigned(aMethod) or
|
||||||
if Assigned(aMethod) and
|
|
||||||
(
|
(
|
||||||
(TMethod(entry^.Method).Code <> TMethod(aMethod).Code) or
|
(TMethod(entry^.Method).Code = TMethod(aMethod).Code) and
|
||||||
(TMethod(entry^.Method).Data <> TMethod(aMethod).Data)
|
(TMethod(entry^.Method).Data = TMethod(aMethod).Data)
|
||||||
) then begin
|
))
|
||||||
|
then begin
|
||||||
|
{ ok, we need to remove this entry }
|
||||||
|
tmpentry := entry;
|
||||||
|
if Assigned(lastentry) then
|
||||||
|
lastentry^.Next := entry^.Next;
|
||||||
|
entry := entry^.Next;
|
||||||
|
if ThreadQueueHead = tmpentry then
|
||||||
|
ThreadQueueHead := entry;
|
||||||
|
if ThreadQueueTail = tmpentry then
|
||||||
|
ThreadQueueTail := lastentry;
|
||||||
|
{ only dispose events added by Queue }
|
||||||
|
if not Assigned(tmpentry^.SyncEvent) then
|
||||||
|
Dispose(tmpentry);
|
||||||
|
end else begin
|
||||||
|
{ leave this entry }
|
||||||
lastentry := entry;
|
lastentry := entry;
|
||||||
entry := entry^.Next;
|
entry := entry^.Next;
|
||||||
Continue;
|
|
||||||
end;
|
end;
|
||||||
{ skip entries added by Synchronize }
|
|
||||||
if Assigned(entry^.SyncEvent) then begin
|
|
||||||
lastentry := entry;
|
|
||||||
entry := entry^.Next;
|
|
||||||
Continue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ ok, we need to remove this entry }
|
|
||||||
|
|
||||||
tmpentry := entry;
|
|
||||||
if Assigned(lastentry) then
|
|
||||||
lastentry^.Next := entry^.Next;
|
|
||||||
entry := entry^.Next;
|
|
||||||
if ThreadQueueHead = tmpentry then
|
|
||||||
ThreadQueueHead := entry;
|
|
||||||
if ThreadQueueTail = tmpentry then
|
|
||||||
ThreadQueueTail := lastentry;
|
|
||||||
{ only dispose events added by Queue }
|
|
||||||
if not Assigned(tmpentry^.SyncEvent) then
|
|
||||||
Dispose(tmpentry);
|
|
||||||
end;
|
end;
|
||||||
{$ifdef FPC_HAS_FEATURE_THREADING}
|
{$ifdef FPC_HAS_FEATURE_THREADING}
|
||||||
finally
|
finally
|
||||||
|
Loading…
Reference in New Issue
Block a user