Subject: Re: [boost] [thread] Obtaining thread id on Windows
From: Agustín K-ballo Bergé (kaballo86_at_[hidden])
Date: 2009-09-11 04:36:03
Yechezkel Mett escribió:
> 2009/9/10 Agustín K-ballo Bergé <kaballo86_at_[hidden]>:
>> 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.
I don't see them as two native thread types. Windows thread id is
consistent with boost::thread::id, while a thread handle isn't. I'm not
experienced with threads other than Windows, but it may just happen that
in other apis a thread id and a thread handle are exactly the same thing.
Compared to C's files, I think of a thread id as the filename and a
thread handle as a FILE*. You can't fread from a filename just as you
can't suspend/resume a thread id. I don't expect a way to check if two
different FILE*s are indeed handles to the same file. And I understand
why I can't get a thread id from a thread handle, just as I can't get a
filename from a FILE*. I just wonder if, since its there, it would make
sense to make it available.
I do think its odd for PostThreadMessage to require an id rather than a
handle. Nevertheless, I've just added a DWORD and a thread::barrier to
my class just to be able to use it, while the value I want is lying
there in Boost.Threads internals.
I am by no means an expert, so please correct me if I'm wrong.
Agustín K-ballo Bergé.-
PS: I've just checked a Pthreads implementation reference online that
provides pthread_getunique_np/pthread_getthreadid_np (non portable) as
ways to obtain a native thread id.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk