Boost logo

Boost :

From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2008-05-28 09:24:58


Stefan Seefeld <seefeld_at_[hidden]> writes:

> I was looking for alternative ways to phrase the "Effects" (in
> particular to express the "joinable" concept, but ran into some issues:
>
> * There doesn't appear to be any means to query a thread object's state.

A thread is either joinable() or not.

> * I can (apparently) invalidate an existing thread object by
> detaching it.

Yes. Then the object ceases to refer to a thread, and thus joinable()
returns false.

> * I can construct a thread that doesn't refer to anything (default
> constructor).

Yes.

> Of course there is 'joinable', but that doesn't let me distinguish
> between a default-constructed ("not-a-")thread, a detached thread, and a
> thread that has already been joined.

No, it doesn't. From the point of view of the thread object they are
all the same: this thread object does not represent a thread, and
therefore is not joinable(). In all three cases the thread::get_id()
member function will return a default-constructed (not-a-thread) ID.

Anthony

-- 
Anthony Williams            | Just Software Solutions Ltd
Custom Software Development | http://www.justsoftwaresolutions.co.uk
Registered in England, Company Number 5478976.
Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

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