Overview
Features
Download
Documentation
Community
Add-Ons & Services

Native Thread-ID

Discussion of ideas for features and new projects based on POCO.

Native Thread-ID

Postby Rabenklaue » 27 Jan 2010, 21:31

Hi, I think it would be nice to get the native ids of the/a running thread additionally to Poco::Thread::id(), which only returns an internal id not representing the actually assigned by the system, e.g. seen with "top" or "ps" on UNIX machines or within the task manager on Windows.

Code: Select all
#if defined(POCO_OS_FAMILY_WINDOWS)
   #include <windows.h>
#elif defined(POCO_OS_FAMILY_UNIX)
   #include <sys/syscall.h>
#endif

// should be renamed to static Poco::Thread::getCurrentThreadId() or something similar
// returning the id of the thread this function is called within
inline unsigned long getCurrentThreadID() {
#if defined(POCO_OS_FAMILY_WINDOWS)
   return (unsigned long)GetCurrentThreadId();
#elif defined(POCO_OS_FAMILY_UNIX)
   return (unsigned long)syscall(SYS_gettid);
#else
   // should use Poco::Thread::id() instead
   return 0;
#endif
}
Rabenklaue
 
Posts: 10
Joined: 22 Jan 2010, 07:08
Location: Germany

Re: Native Thread-ID

Postby guenter » 27 Jan 2010, 22:33

guenter
 
Posts: 1165
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Native Thread-ID

Postby Rabenklaue » 27 Jan 2010, 23:16


Gentoo only provides 1.3.3_p1, so I missed that Thread::tid() implementation. Thanks guenter.
Rabenklaue
 
Posts: 10
Joined: 22 Jan 2010, 07:08
Location: Germany


Return to Wishlist

Who is online

Users browsing this forum: No registered users and 0 guests

cron