Boost logo

Boost :

Subject: Re: [boost] [thread] Obtaining thread id on Windows
From: Yechezkel Mett (ymett.on.boost_at_[hidden])
Date: 2009-09-10 06:35:52


2009/9/10 Agustín K-ballo Bergé <kaballo86_at_[hidden]>:
> I've found a need to retrieve a thread id rather than a thread handle on
> Windows. There is no documented way to get it from the handle on XP (see
> http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/89728ee1-d9d8-4cfa-ba91-cfd92f31c208
> ). Would it make sense to add a get_native_id member function?

boost::thread and std::thread don't know what the native thread type
is, nor do they know that Windows has two native thread types. The
correct solution seems to be:

struct native_handle_type
{
  HANDLE handle;
  DWORD id;

  // perhaps, for backward compatibilty
  operator HANDLE() { return handle; }
};

In other words it's a QOI detail.

Yechezkel Mett


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk