Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
Re: Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods [message #30577 is a reply to message #30575] Sun, 09 January 2011 22:49 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14265
Registered: November 2005
Ultimate Member
tojocky wrote on Sun, 09 January 2011 16:28

mirek wrote on Sat, 08 January 2011 14:07

Ok, added this:

ThreadId does not make sense for me now (IMO: it is Win32 specific and not really related to Thread).



Mirek,

I think that you are not right according by:
http://suacommunity.com/dictionary/pthread_self-entry.php

Quote:

In the Windows threading model each created thread has both a HANDLE and a system-wide unique id. As a result the GetCurrentThreadId Windows function returns the same logical information as the POSIX call.


The method DWORD WINAPI GetCurrentThread(void) returns the pseudo-handle, that is not same with the result _beginthreadex(...).

In the other had, you are right, because in POSIX you can manage with the result pthread_self.

In the end, I need an unique Thread ID.



Well, true, but we should find a better method how to integrate it..


Quote:


mirek wrote on Sat, 08 January 2011 14:07

Ok, added this:

ThreadId does not make sense for me now (IMO: it is Win32 specific and not really related to Thread).

Note: The faster alternative to all this might be checking the pointer to TLS variable.

About Your Note, can you give me an example, please?

Thank you in advance!

Added:
By TLS variable you mean: Thread-local storage variable?

Like this:
thread__ bool sThreadId;

qword GetCurrentThreadIdCustom(){
 return (qword (&sThreadId));
}



Basically yes. If inlined, it should translate into simple [fs] based load CPU op... (no calls to API).

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: CppBase/Parser.cpp patch (SVN r2960)
Next Topic: virtual void Ctrl::PaintOver(Draw& w) new method
Goto Forum:
  


Current Time: Fri Jul 04 15:40:53 CEST 2025

Total time taken to generate the page: 0.04076 seconds