mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-16 02:29:53 +02:00
* fixed datarace in CBeginThread
git-svn-id: trunk@5274 -
This commit is contained in:
parent
df6fec5301
commit
4240479f5d
@ -326,7 +326,7 @@ const
|
|||||||
|
|
||||||
{ assume that this program will not spawn other threads, when the
|
{ assume that this program will not spawn other threads, when the
|
||||||
first thread is started the following constants need to be filled }
|
first thread is started the following constants need to be filled }
|
||||||
IsMultiThread : boolean = FALSE;
|
IsMultiThread : longbool = FALSE;
|
||||||
{ set to true, if a threading helper is used before a thread
|
{ set to true, if a threading helper is used before a thread
|
||||||
manager has been installed }
|
manager has been installed }
|
||||||
ThreadingAlreadyUsed : boolean = FALSE;
|
ThreadingAlreadyUsed : boolean = FALSE;
|
||||||
|
@ -201,12 +201,14 @@ Type PINTRTLEvent = ^TINTRTLEvent;
|
|||||||
{$endif DEBUG_MT}
|
{$endif DEBUG_MT}
|
||||||
{ Initialize multithreading if not done }
|
{ Initialize multithreading if not done }
|
||||||
if not IsMultiThread then
|
if not IsMultiThread then
|
||||||
begin
|
begin
|
||||||
{ We're still running in single thread mode, setup the TLS }
|
if (InterLockedExchange(longint(IsMultiThread),1) = 0) then
|
||||||
pthread_key_create(@TLSKey,nil);
|
begin
|
||||||
InitThreadVars(@CRelocateThreadvar);
|
{ We're still running in single thread mode, setup the TLS }
|
||||||
IsMultiThread:=true;
|
pthread_key_create(@TLSKey,nil);
|
||||||
end;
|
InitThreadVars(@CRelocateThreadvar);
|
||||||
|
end
|
||||||
|
end;
|
||||||
{ the only way to pass data to the newly created thread
|
{ the only way to pass data to the newly created thread
|
||||||
in a MT safe way, is to use the heap }
|
in a MT safe way, is to use the heap }
|
||||||
new(ti);
|
new(ti);
|
||||||
|
Loading…
Reference in New Issue
Block a user