mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-06 23:10:31 +02:00
* avoid a datarace in case a worker thread finishes and the main thread sees
that it is done before it had the chance to call RTLEventSetEvent() (since then no memory barrier synchronised the thread state with what the main thread would see) git-svn-id: trunk@34401 -
This commit is contained in:
parent
9487b46b8a
commit
7eea450a52
@ -2832,6 +2832,12 @@ procedure TCompileWorkerThread.execute;
|
||||
begin
|
||||
while not Terminated do
|
||||
begin
|
||||
{ Make sure all of our results are committed before we set (F)Done to true.
|
||||
While RTLeventSetEvent implies a barrier, once the main thread is notified
|
||||
it will walk over all threads and look for those that have Done=true -> it
|
||||
can look at a thread between that thread setting FDone to true and it
|
||||
calling RTLEventSetEvent }
|
||||
WriteBarrier;
|
||||
FDone:=true;
|
||||
RTLeventSetEvent(FNotifyMainThreadEvent);
|
||||
RTLeventWaitFor(FNotifyStartTask,500);
|
||||
@ -7486,6 +7492,8 @@ Var
|
||||
begin
|
||||
if AThread.Done then
|
||||
begin
|
||||
{ synchronise with the WriteBarrier in the thread }
|
||||
ReadBarrier;
|
||||
if assigned(AThread.APackage) then
|
||||
begin
|
||||
// The thread has completed compiling the package
|
||||
|
Loading…
Reference in New Issue
Block a user