mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-20 18:09:08 +02:00
* cache result of GetThreadManager in InitThreads
git-svn-id: trunk@8245 -
This commit is contained in:
parent
e205481027
commit
f3a00b0731
@ -62,7 +62,19 @@ begin
|
|||||||
{ operation having been finished by another thread already, it will }
|
{ operation having been finished by another thread already, it will }
|
||||||
{ use an uninitialised thread manager -> leave as it is }
|
{ use an uninitialised thread manager -> leave as it is }
|
||||||
if not ThreadsInited then
|
if not ThreadsInited then
|
||||||
|
begin
|
||||||
GetThreadManager(CurrentTM);
|
GetThreadManager(CurrentTM);
|
||||||
|
{$ifdef FPC_HAS_MEMBAR}
|
||||||
|
{ however, we have to ensure that a thread never sees ThreadsInited }
|
||||||
|
{ as true while CurrentTM hasn't been initialised yet }
|
||||||
|
WriteBarrier;
|
||||||
|
ThreadsInited := True;
|
||||||
|
{$endif}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
{ See double checked lock example at }
|
||||||
|
{ http://ridiculousfish.com/blog/archives/2007/02/17/barrier }
|
||||||
|
ReadDependencyBarrier;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure DoneThreads;
|
procedure DoneThreads;
|
||||||
|
Loading…
Reference in New Issue
Block a user