[fpc-devel] TThread.Terminate;
Jonas Maebe
jonas at freepascal.org
Sat Aug 22 16:57:48 CEST 2020
On 22/08/2020 16:09, Martin via fpc-devel wrote:
> procedure TThread.Terminate;
> begin
> FTerminated := True;
> end;
>
> Should that not in some way deal with memory barriers? E.g.
> InterlockedExchange or similar?
Very important: InterlockedExchange is not a memory barrier, except on x86.
> And the same for the "Terminated" property, should that have a getter to
> do the same?
>
> As it stands, afaik a thread could get the "Terminate" flag with an
> unknown delay?
It's not a semaphore/signal, it's just a field. It will never be
instantaneous since it can only have an effect once the target thread
actually tries to read it. Wrapping it in a bunch of synchronisation
primitives will make the whole system slower with no real benefit.
Jonas
More information about the fpc-devel
mailing list