Topic: Possible incoherence in thread::get_id and this_thread::get_id


Author: viboes <vicente.botet@wanadoo.fr>
Date: Mon, 22 Nov 2010 01:03:37 CST
Raw View
Hi,

When a thread is detached thread::get_id() == thread::id(). This is
not the case for this_thread::get_id(). Is there a reason to have this
behavior, or should this_thread::get_id() return also thread::id()
after the thread has been detached?

thread::id thread::get_id() const;
16 Returns: A default constructed id object if *this does not
represent a thread, otherwise this_thread::get_id() for the thread of
execution represented by *this.

thread::id this_thread::get_id();
1 Returns: An object of type thread::id that uniquely identifies the
current thread of execution. No other thread of execution shall have
this id and this thread of execution shall always have this id. The
object returned shall not compare equal to a default constructed
thread::id.

Best,
Vicente


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: =3D?ISO-8859-1?Q?Daniel_Kr=3DFCgler?=3D <daniel.kruegler@googlemail.c=.om>
Date: Mon, 22 Nov 2010 13:40:20 CST
Raw View
On 11/22/2010 08:03, viboes wrote:

>
> Hi,
>
> When a thread is detached thread::get_id() == thread::id(). This is
> not the case for this_thread::get_id(). Is there a reason to have this
> behavior, or should this_thread::get_id() return also thread::id()
> after the thread has been detached?
>
> thread::id thread::get_id() const;
> 16 Returns: A default constructed id object if *this does not
> represent a thread, otherwise this_thread::get_id() for the thread of
> execution represented by *this.
>
> thread::id this_thread::get_id();
> 1 Returns: An object of type thread::id that uniquely identifies the
> current thread of execution. No other thread of execution shall have
> this id and this thread of execution shall always have this id. The
> object returned shall not compare equal to a default constructed
> thread::id.
>

There is already an existing library issue for this:

http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#1486

In regard to your recommendation: Note also that another issue exists,

http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#1485

that alludes that the current wording is not really clear about thread ids
of detached threads.

Both issues still have status "Open", so not much can be said about the
possible directions now.

HTH & Greetings from Bremen,

Daniel Kr=FCgler


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]