FXThread::current() changed behavior between FOX-1.6.x and FOX-1.7 in WIN32
Martin Oberzalek <[email protected]>
| Newsgroups | gmane.comp.lib.fox-toolkit.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
my app used FXThread::current() to have a kind of identifier for each
thread. So a central function was able to know wich thread called it,
without the need for getting an extra handle to the thread class
itself.
I implemented a thread specific cache this way. However...
A recent dev FOX version returns GetCurrentThread() on WIN32.
The current code is:
// Return thread id of caller
FXThreadID FXThread::current(){
#if defined(WIN32)
//return (FXThreadID)GetCurrentThreadId();
return (FXThreadID)GetCurrentThread();
#else
return (FXThreadID)pthread_self();
#endif
}
But GetCurrentThread() returns a pseudo handle. It is always
0xFFFFFFFFFFFFFFFE or in decimal: it is always -2
https://learn.microsoft.com/en-
us/windows/win32/api/processthreadsapi/nf-processthreadsapi-
getcurrentthread
The Unix version pthread_self() returns always the same handle, that
returned when creating a thread.
https://man7.org/linux/man-pages/man3/pthread_self.3.html
The pthread_self() function returns the ID of the calling thread.
This is the same value that is returned in *thread in the
pthread_create(3) call that created this thread.
so implified:
for POSIX systems: pthread_create() == pthread_self()
for WIN32 systems: CreateThread() == GetCurrentThreadId()
I suggest swithing back to the GetCurrentThreadId() version,
otherwise it would be wise to dokument the different behaviour between
POSIX and WIN32
If you wan't I can send you a patch.
Regards, and thank you for your work,
Greetings, Martin
--
2*Pi || !(2*Pi) this == ?
http://redeye.hoffer.cx/
http://borger.co.at/
_______________________________________________
Foxgui-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/foxgui-users