Boost logo

Boost :

From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2001-08-18 12:18:07


> > > Unfortunately, without garbage collection, the references would
become
> > > invalid when 'f' returns (without warning.)
> >
> > why? for "joinable" threads when f returns, nothing terrible
> > (with respect to thread objects - C++ and/or native) really
> > happens.. only "join" would explicitly destroy native thread
> > object (after awaiting thread termination, implicit destruction
> > via "detach" aside; IMHO that should only be done for dynamic
> > C++ thread objects; btw native thread objects (represented by
> > pthread_t/HANDLE) are always dynamic).
>
> Because the thread may run to completion without being joined, and the
> thread object will have to be destroyed, invalidating references.

neither windows nor pthreads destroy their internal
dynamic thread objects when threads run to completion
(unless you have explicitly asked for implicit/auto
destruction on thread termination via "detach";
pthreads: PTHREAD_CREATE_DETACHED/pthread_detach,
windows: close handle returned from CreateThread/last
replica handle).

why C++ library should do it differently?

regards,
alexander.


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