Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2021-03

function GetCurrentThreadId vs variable ThreadID

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Alexander Grotewohl
to Martin

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..

Alexander Grotewohl https://dcclost.com ________________________________
Earlier message 15 lines
From: fpc-devel on behalf of Martin via fpc-devel Sent: Sunday, March 28, 2021, 3:35 PM To: fpc-devel Cc: Martin Subject: [fpc-devel] function GetCurrentThreadId vs variable ThreadID I looked at the doc https://www.freepascal.org/docs-html/rtl/system/getcurrentthreadid.html https://www.freepascal.org/docs-html/rtl/system/threadid.html But the entry for ThreadId only says "Current Thread ID." Which is not distinguishing it from GetCurrentThreadId. So what is the difference?

Reply by email

Sven Barth
to Alexander Grotewohl
Alexander Grotewohl wrote 5 lines
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

Reply by email