Boost logo

Boost :

From: williamkempf_at_[hidden]
Date: 2001-07-02 12:37:52


--- In boost_at_y..., "Alexander Terekhov" <terekhov_at_d...> wrote:
>
>
> > > > void foo()
> > > > {
> > > > thread thrd(&bar);
> > > > }
> > >
> > > Question: can a thread run without a corresponding thread
object?
> >
> > Yes. This is a "detached" thread.
>
> NO. A thread can not run without corresponding thread object.
> it is just like "running" without thread stack / priority / other
> thread identities. "detached" means that that thread object will
> be destroyed/reclaimed _automatically_ on thread termination.

Sorry, this isn't correct in the current context. A "thread object"
in this context is *NOT* the thread itself (i.e. it's not the state
information such as stack, instruction pointer, priority, et. al.),
it's only an object that represents this state. The state lives
until the thread is destroyed, but the thread object does not
(necessarily).

> in the example above "detach" does not make sense, IMHO.
> instead, pre-destructor should join and destructor should reclaim
> other resources..

Sorry, but I don't agree that the destructor (pre- if you prefer the
term, though there is no such thing in C++) should join. This forces
us to always join threads, which we simply do not do. Again, POSIX
supports the concepts I'm discussing here, though they use differing
semantics that are slighly more well defined then what we have during
this design discussion.

Bill Kempf


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