Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-08-31 10:46:56


From: "William Kempf" <williamkempf_at_[hidden]>
> The issue, again (we both keep saying the same thing here so we're both
> getting frustrated), is that you can not tell when a thread is adopted.

Replace 'adopted' with 'default-constructed.'

["you've accused me of" paragraphs omitted]

> And regardless of this, I've still not seen how the current thread design
> prevents such a thread_ref design from being implemented (except for the
> "initial thread" case, which you've not shown how this could be treated
> differently by either Boost.Threads or POSIX/Win32).

Again, pretend that in this subthread thread_ref doesn't exist. It is
strictly about your boost::thread::join; nothing else.

> You've lost me. Case 3 doesn't exist, and if it would it would still be
> thread safe.

OK.

Imagine the following alternative definition of join:

Preconditions: *this != thread() and *this has not been default-constructed.
Effects: blocks until the thread represented by *this terminates and its
resources have been reclaimed.

This is the hypothetical case 3. Joins are serialized, and the behavior of
join is well defined when called multiple times on the same object, whether
concurrently or in sequence.

This is the design that I like.

--
Peter Dimov
Multi Media Ltd.

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