[fpc-devel] function GetCurrentThreadId vs variable ThreadID

Sven Barth pascaldragon at googlemail.com
Sun Apr 4 20:18:12 CEST 2021


Am 28.03.2021 um 21:46 schrieb Alexander Grotewohl via fpc-devel:
> looks like threadid is assigned to getcurrentthreadid in an 
> initthread() function in thread.inc.
>
> but: getcurrentthreadid looks to be mapped to a changeable thread 
> manager which is why that might seem weird in the docs..

Correct. GetCurrentThreadID always calls through the thread manager to 
retrieve the current thread's ID while ThreadID is initialized in the 
thread's initialization. This make a difference if you're dealing with 
external threads (those not started through the RTL, but from e.g. C 
code). Though depending on the threading implementation it /might/ be 
that it sets up ThreadID nevertheless. In essence: Best use 
GetCurrentThreadID.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20210404/4b46163c/attachment.htm>


More information about the fpc-devel mailing list