mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 13:09:22 +02:00
* make webtbs/tw30535 also working on OSes using cthreads
git-svn-id: trunk@35570 -
This commit is contained in:
parent
b55cb246da
commit
1b371b15e3
@ -306,10 +306,14 @@ Type PINTRTLEvent = ^TINTRTLEvent;
|
|||||||
pthread_exit(ThreadMain);
|
pthread_exit(ThreadMain);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure InitCThreading;
|
|
||||||
|
var
|
||||||
|
TLSInitialized : longbool = FALSE;
|
||||||
|
|
||||||
|
Procedure InitCTLS;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if (InterLockedExchange(longint(IsMultiThread),ord(true)) = 0) then
|
if (InterLockedExchange(longint(TLSInitialized),ord(true)) = 0) then
|
||||||
begin
|
begin
|
||||||
{ We're still running in single thread mode, setup the TLS }
|
{ We're still running in single thread mode, setup the TLS }
|
||||||
pthread_key_create(@TLSKey,nil);
|
pthread_key_create(@TLSKey,nil);
|
||||||
@ -338,8 +342,10 @@ Type PINTRTLEvent = ^TINTRTLEvent;
|
|||||||
writeln('Creating new thread');
|
writeln('Creating new thread');
|
||||||
{$endif DEBUG_MT}
|
{$endif DEBUG_MT}
|
||||||
{ Initialize multithreading if not done }
|
{ Initialize multithreading if not done }
|
||||||
if not IsMultiThread then
|
if not TLSInitialized then
|
||||||
InitCThreading;
|
InitCTLS;
|
||||||
|
IsMultiThread:=true;
|
||||||
|
|
||||||
{ 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);
|
||||||
@ -817,7 +823,7 @@ begin
|
|||||||
Writeln('InitThreads : ',Result);
|
Writeln('InitThreads : ',Result);
|
||||||
{$endif DEBUG_MT}
|
{$endif DEBUG_MT}
|
||||||
// We assume that if you set the thread manager, the application is multithreading.
|
// We assume that if you set the thread manager, the application is multithreading.
|
||||||
InitCThreading;
|
InitCTLS;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function CDoneThreads : Boolean;
|
Function CDoneThreads : Boolean;
|
||||||
|
Loading…
Reference in New Issue
Block a user