Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-06-28 13:15:29


In pthreads, detached means that when a thread terminates the resources
(stack, etc.) used by the thread will be reclaimed immediately. If a
thread is not detached, the resources will not be reclaimed until a join
happens (which automatically makes the thread detached) or until the
process finishes. In pthreads you can not join a thread that is already
detached. A thread can be created in the detached state, or
pthread_detach() can be called to put a thread into the detached state.
Chapter 2 of "Programming with POSIX Threads" describes all of this.

If detached means something very different under Windows, perhaps we
should use a different word for it.

Cheers,
Jeremy

On Thu, 28 Jun 2001, Greg Colvin wrote:
> I guess it depends on what "detach" means. I don't know pthreads, but
> on Windows issue then is just , I think, whether to just close handle
> in the destructor or wait for the thread to complete.
>
> I think for the thread::ref doing a join() in the destructor would be
> silly, what with many copies of the ref possibly spread all over the
> program, but it might make sense for the thread destructor, assuming
> there is even a thread class to have a destructor.
>
> From: Jeremy Siek <jsiek_at_[hidden]>
> >
> > If the thread is going to be detached, why not just create it as detached
> > from the start, instead of waiting until the destructor? I don't see how
> > the lifetime of some thread ref object has anything to do with a detached
> > thread.

----------------------------------------------------------------------
 Jeremy Siek www: http://www.lsc.nd.edu/~jsiek/
 Ph.D. Candidate, IU B'ton email: jsiek_at_[hidden]
 Summer Manager, AT&T Research phone: (973) 360-8185
----------------------------------------------------------------------


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