On 13.04.2013 16:06, Anthony Walter wrote:
Oh, I just thought of a followup question. If I have to call BeginThread
to make the memory manager/rtl "thread aware", do I then have to also
have to check the OS type (and maybe the CPU architecture)

No, you need to do this for every system. BeginThread is supported everywhere where threading is supported (and it's used internally by TThread).

and possibly
add more units? Is it safe to call BeginThread on all
platforms/architectures using only the System unit?


On certain platforms (e.g. Unix ones) you need to add the cthreads unit (or whereever the thread manager is implemented).

It's not depending on the platform (though I wouldn't bet on m68k supporting threads correctly currently ^^)

{ifdef $unix}
{ Do I still need this the line below?
   Do I need to be concerned with different OSes or CPU architectures in
the line below?
   Android ARM, Raspberry Pi ARM, OSX, iOS with whatever CPU ... ? }
uses cthreads;

This line (or a similar one) is needed only on systems where the thread manager is not included in the system unit (e.g. not on Windows systems)

{$endif}

function ThreadFunc(Parameter: Pointer): PtrInt;
begin
EndThread(0);
end;

procedure InitThreadAware;
begin
   BeginThread(@ThreadFunc);
end;

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to