* cache result of GetThreadManager in InitThreads

git-svn-id: trunk@8245 -
This commit is contained in:
Jonas Maebe 2007-08-08 11:33:54 +00:00
parent e205481027
commit f3a00b0731

View File

@ -62,7 +62,19 @@ begin
{ operation having been finished by another thread already, it will }
{ use an uninitialised thread manager -> leave as it is }
if not ThreadsInited then
GetThreadManager(CurrentTM);
begin
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;
procedure DoneThreads;