|
|
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   |
 |
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
|
|
|
 |
|
Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
By: tojocky on Fri, 07 January 2011 16:38
|
 |
|
Re: Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
By: mirek on Sat, 08 January 2011 13:07
|
 |
|
Re: Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
By: tojocky on Sun, 09 January 2011 22:28
|
 |
|
Re: Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
By: mirek on Sun, 09 January 2011 22:49
|
 |
|
Re: Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
By: tojocky on Mon, 10 January 2011 15:35
|
 |
|
Re: Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
|
 |
|
Re: Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
By: mirek on Mon, 10 January 2011 17:48
|
 |
|
Re: Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
By: tojocky on Mon, 10 January 2011 19:13
|
 |
|
Re: Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
By: mirek on Tue, 11 January 2011 14:49
|
 |
|
Re: Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
By: tojocky on Tue, 11 January 2011 16:11
|
 |
|
Re: Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
By: mirek on Wed, 12 January 2011 09:49
|
 |
|
Re: Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
By: tojocky on Wed, 12 January 2011 12:36
|
 |
|
Re: Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
By: mirek on Wed, 12 January 2011 20:40
|
 |
|
Re: Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
By: tojocky on Thu, 13 January 2011 11:47
|
 |
|
Re: Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
By: mirek on Thu, 13 January 2011 20:51
|
 |
|
Re: Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
By: tojocky on Fri, 14 January 2011 08:12
|
Goto Forum:
Current Time: Fri Jul 04 15:40:53 CEST 2025
Total time taken to generate the page: 0.04076 seconds
|
|
|