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 #30575 is a reply to message #30556] Sun, 09 January 2011 22:28 Go to previous messageGo to previous message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

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.

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));
}

[Updated on: Sun, 09 January 2011 22:37]

Report message to a moderator

 
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: Tue May 21 10:25:23 CEST 2024

Total time taken to generate the page: 0.02298 seconds